function encrypt(text) { if(!text || !options.cipher) return text; var key = _.isString(options.key) ? new Buffer(options.key,'hex') : options.key; var cipher = crypto.createCipher(options.cipher, key); var crypted = cipher.update(text, 'utf8', 'binary'); crypted += cipher.final('binary'); return base58.encode(new Buffer(crypted, 'binary')); }
crypto.pbkdf2(password, salt, iterations, keylength, function(err, key) { if(err) return callback(err); var res = ['pbkdf2', iterations, keylength, base58.encode(key), base58.encode(salt)].join(':'); callback(null, res); })