Reusable pieces of code and docs pointers to get started with DES encryption in node.
DES-ECB
function encodeDesECB(textToEncode, keyString) { |
The key needs to be 8-bit, you can change the code to use 'ascii'
, 'utf8'
, 'utf16le'
, 'ucs2'
, 'base64'
, 'binary'
or 'hex'
. More info here
For the input and output encodings in cipher.update(data[, input_encoding][, output_encoding])
, check the documentation here
For the final encoding in cipher.final([output_encoding])
, check the documentation here
DES-CBC
function encodeDesCBC(textToEncode, keyString, ivString) { |
The iv (Initialization Vector) needs to be 8-bit, same as the key.