encrypt/decrypt data to store on cookie, with memoization
npm install cookie-encryption




Encrypt/decrypt data to store on cookie, with memoization.
This class is built with
arc4 cipher,
autokey cipher,
nodejs ciphers,
nodejs hash,
nodejs hmac,
nodejs pbkdf2 and
nodejs diffiehellman,
Install through NPM
``bash`
npm install cookie-encryption`
orbash`
git clone git://github.com/hex7c0/cookie-encryption.git
inside expressjs project
`js
var cookiee = require('cookie-encryption');
var vault = cookiee('ciao');
`
return supported ciphers
`js
var cookiee = require('cookie-encryption');
cookiee.getCiphers();
`
Check Cookie options
write data ('pippo') to selected cookie
`js`
vault.write(req, 'pippo');
read data from selected cookie
`js`
vault.read(req);
flush data cache
`js`
vault.flush();
optional arguments inside of previous methods
``
* @param {String} [cookie] - fast cookie
* @param {String} [encoding] - fast encoding
#### secret
- secret- String | Buffer Set password (default "required")
#### [options]
- cipher - String Type of cipher, grab list from getCiphers (default "arc4")domain
- - String Domain of cookie (default "null")cookie
- - String Name of cookie (default "vault")path
- - String Path of cookie (default "/")maxAge
- - Number Age of cookie in millisecond (default "1 year")httpOnly
- - Boolean Flag for http only cookie (default "false")secure
- - Boolean Flag for using cookie over TLS/SSL (default "false")signed
- - Boolean Will use the secret passed to cookieParser(secret) to sign the value (default "false")encoding
- - String Type of output encoding by nodejs (default "hex")extra
- - Array Extra info for Hmac ([true] to enable instead of Hash) and pbkdf2 ([salt, iterations, keylen]) (default "[ ]`")
Take a look at my examples