xsalsa20-encoding
XSalsa20 codec that implements that abstract-encoding interface. Nonces are generated randomly and prepended to the ciphertext.
Installation
$ npm install xsalsa20-encoding
Usage
const codec = secretKey // encode a valuebuffer = codec // decode a valuevalue = codec
Example
const crypto = const Codec = const key = crypto const codec = const hello = codecconst world = codec console // 'hello world'
Custom Value Encodings
const pbs = const Message = const codec = const encoded = codecconst message = codec // { data: 'hello world' }
API
codec = require('xsalsa20-encoding')([secretKey[, opts])
Create a codec object from 32 byte secretKey
.
const key = cryptoconst codec =
buffer = codec.encode(value[, output[, offset]])
Encode a value using xsalsa20
(XOR) into an optional output
buffer at an optional offset
defaulting to 0
. If an output
buffer is not given, one is allocated
for you and returned.
const buffer = codec
value = codec.decode(buffer[, offset])
Decode a buffer using xsalsa20
(XOR) at an optional offset
defaulting to 0
.
const value = codec
length = codec.encodingLength(value)
Returns the encoding length for a given value
.
const length = codec // 35
License
MIT