Use node's crypto API for pasteboard md5s

This commit is contained in:
Kevin Sawicki
2013-03-11 19:07:08 -07:00
parent 9139df5779
commit 2a78183a15
2 changed files with 6 additions and 394 deletions

View File

@@ -1,16 +1,19 @@
{hex_md5} = require 'md5'
crypto = nodeRequire 'crypto'
module.exports =
class Pasteboard
signatureForMetadata: null
md5: (text) ->
crypto.createHash('md5').update(text).digest('hex')
write: (text, metadata) ->
@signatureForMetadata = hex_md5(text)
@signatureForMetadata = @md5(text)
@metadata = metadata
$native.writeToPasteboard(text)
read: ->
text = $native.readFromPasteboard()
value = [text]
value.push(@metadata) if @signatureForMetadata == hex_md5(text)
value.push(@metadata) if @signatureForMetadata == @md5(text)
value