balor/connect-memcached — pull request #13 by jas- (2014-02-04 13:01:48+00:00)
Title: Transparent encryption support

This PR will provide optional encryption support for all session data set and retrieved from the memcached service. Please see the [OWASP Session Management (session content)](https://www.owasp.org/index.php/Session_Management_Cheat_Sheet#Session_ID_Content_.28or_Value.29) documentation for reasoning behind adding this support.

lib/connect-memcached.js:
Configuration:
- Optionally specify a 'secret' and 'algorithm' (valid list retrieved from
crypto.getCiphers())
Public:
- MemcachedStore.prototype.set: Encrypts data based on 'secret' option
- MemcachedStore.prototype.get: Decrypts data based on 'secret' option
Private:
- encryptData(plaintext): Wrapper for encrypting data using specified key & algorithm
while also creating a MAC based on results of encryption.
- decryptData(ciphertext): Wrapper for decrypting data. First performs validation of
cipher text based on stored MAC value, then decrypts payload.
- digest(key, ct): Creates an SHA512 MAC of cipher text & is used to verify stored
cipher text for tampering.
- encrypt(key, pt, algo): Generates cipher text value based on supplied secret & algorithm.
- decrypt(key, ct, algo): Decrypts cipher text to plain text using supplied secret & algorithm.

Readme.md:
Updated example & list of configuration options to reflect this pull request's
functionality.