util/cipherUtil.js
function pwDecipher(string) {

        if(string) {

            if ( typeof pw !== 'string' || pw.length < 8 ) {
                throw new Error('Please set a password with 8 or ' +
                    'more chars on process.env.CIPHER_UTIL_PW!');
            }

            if ( typeof algo !== 'string' || algo.length < 1 ) {
                throw new Error('Please choose an algorithm' +
                    ' on process.env.CIPHER_UTIL_ALGO!');
            }

            var buffer = new Buffer(string, pwEnc),

            toDecipher = crypto.createDecipher(algo, pw),

            deciphered = [toDecipher.update(buffer)];

            deciphered.push(toDecipher.final());

            return Buffer.concat(deciphered).toString(dec);

        }

        return null;

    }
function pwDecipher(string) {

        if(string) {

            if ( typeof pw !== 'string' || pw.length < 8 ) {
                throw new Error('Please set a password with 8 or ' +
                    'more chars on process.env.CIPHER_UTIL_PW!');
            }

            if ( typeof algo !== 'string' || algo.length < 1 ) {
                throw new Error('Please choose an algorithm' +
                    ' on process.env.CIPHER_UTIL_ALGO!');
            }

            var buffer = new Buffer(string, pwEnc),

            toDecipher = crypto.createDecipher(algo, pw),

            deciphered = [toDecipher.update(buffer)];

            deciphered.push(toDecipher.final());

            return Buffer.concat(deciphered).toString(dec);

        }

        return null;

    }
function pwDecipher ( string ) { if ( string ) { if ( typeof pw !== 'string' || pw . length < 8 ) { throw new Error ( 'Please set a password with 8 or ' + 'more chars on process.env.CIPHER_UTIL_PW!' ) ; } if ( typeof algo !== 'string' || algo . length < 1 ) { throw new Error ( 'Please choose an algorithm' + ' on process.env.CIPHER_UTIL_ALGO!' ) ; } var buffer = new Buffer ( string , pwEnc ) , toDecipher = crypto . createDecipher ( algo , pw ) , deciphered = [ toDecipher . update ( buffer ) ] ; deciphered . push ( toDecipher . final ( ) ) ; return Buffer . concat ( deciphered ) . toString ( dec ) ; } return null ; }
Decrypt string with password and specified algorithm.

@param string {String} String to decrypt.
@return {String | Null}
Decrypt string with password and specified algorithm .