mirror of
https://github.com/atom/atom.git
synced 2026-02-06 20:55:33 -05:00
Use node's crypto API for pasteboard md5s
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user