Move memory helpers to their own module
This commit is contained in:
parent
e77c70ef71
commit
e9ac929b5a
13
index.js
13
index.js
@ -2,24 +2,13 @@
|
|||||||
|
|
||||||
// Based on https://github.com/dchest/tweetnacl-js/blob/6dcbcaf5f5cbfd313f2dcfe763db35c828c8ff5b/nacl-fast.js.
|
// Based on https://github.com/dchest/tweetnacl-js/blob/6dcbcaf5f5cbfd313f2dcfe763db35c828c8ff5b/nacl-fast.js.
|
||||||
|
|
||||||
var sodium = module.exports
|
|
||||||
|
|
||||||
// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
|
// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
|
||||||
// Public domain.
|
// Public domain.
|
||||||
//
|
//
|
||||||
// Implementation derived from TweetNaCl version 20140427.
|
// Implementation derived from TweetNaCl version 20140427.
|
||||||
// See for details: http://tweetnacl.cr.yp.to/
|
// See for details: http://tweetnacl.cr.yp.to/
|
||||||
|
|
||||||
// also forwarded at the bottom but randombytes is non-enumerable
|
forward(require('./memory'))
|
||||||
|
|
||||||
sodium.sodium_memzero = function (arr) {
|
|
||||||
arr.fill(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
sodium.sodium_malloc = function (n) {
|
|
||||||
return new Uint8Array(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
forward(require('./crypto_box'))
|
forward(require('./crypto_box'))
|
||||||
forward(require('./crypto_generichash'))
|
forward(require('./crypto_generichash'))
|
||||||
forward(require('./crypto_hash'))
|
forward(require('./crypto_hash'))
|
||||||
|
Loading…
Reference in New Issue
Block a user