Utility wrapper around libsodium (via sodium-universal) for use in node-wot.
See the test file for usage examples
Returns a hex string, which will have a character length double of the length you passed in
pass
is a utf8 string
salt
is optional -- if absent, it will be created. You should save it for re-hashing; it is not private.
salt
is a hex string
callback
is a function that receives (err, {salt, secret})
. salt
and secret
are both hex strings.
Symmetric encryption of some text using a secret key.
secret
should be the secret
generated by hashPass
and received in the callback -- it is a hex string
plainText
is a utf8 string
Returns a hex string
Symmetric decryption of some text using the same secret key you encrypted it with.
secret
should be the secret
generated by hashPass
and received in the callback -- it is a hex string.
encrypted
is a hex string returned by encrypt
Throws an error if the decryption fails.
Returns a utf8 string of the original plaintext
seed
should be the secret
generated by hashPass
and received in the callback -- it is a hex string.
Returns an object of {pk, sk}
where pk
is their public signing key and sk
is their secret signing key. Both are hex strings.
seed
should be the secret
generated by hashPass
and received in the callback -- it is a hex string.
Returns an object of {pk, sk}
where pk
is their public encryption key and sk
is their secret encryption key. Both are hex strings.
message
is a utf8 string
sk
is the signing secret key returned by createSignKeypair
-- it is a hex string
Returns a signed message (hex string)
signedMessage
is a hex string returned by sign
pk
is the public signing key returned by createSignKeypair
-- it is a hex string
Throws an error if the signature can't be verified.
Returns a utf8 string of the original unsigned message.
message
is a utf8 string
pk
is the public encryption key returned by createBoxKeypair
-- it is a hex string
sk
is the secret encryption key returned by createBoxKeypair
-- it is a hex string
Returns a hex string
encryptedMessage
is a hex string returned by createBox
pk
is the public encryption key returned by createBoxKeypair
-- it is a hex string
sk
is the secret encryption key returned by createBoxKeypair
-- it is a hex string
Throws an error if the decryption fails.
Returns a utf8 string of the original plaintext message.
message
is a utf8 string
Returns a hex string
message
is a utf8 string
sk
is the signing secret key returned by createSignKeypair
-- it is a hex string
Returns a hex string
signedHash
is a hex string returned by hashAndSign
originalMessage
is a utf8 string that exactly matches the message
passed into hashAndSign
pk
is the public signing key returned by createSignKeypair
-- it is a hex string
Throws an error if the hash does not match the original message, or if the signature can't be verified.
Returns the unsigned hash (hex string)