transporterReceive(next) { return (cmd, data, s) => { const decrypter = iv ? crypto.createDecipheriv(algorithm, password, iv) : crypto.createDecipher(algorithm, password); const res = Buffer.concat([decrypter.update(data), decrypter.final()]); return next(cmd, res, s); }; }
async getFileData(filename) { const bucket = await this._getBucket(); const stream = bucket.openDownloadStreamByName(filename); stream.read(); return new Promise((resolve, reject) => { const chunks = []; stream.on('data', data => { chunks.push(data); }); stream.on('end', () => { const data = Buffer.concat(chunks); if (this._fileKey !== null) { const authTagLocation = data.length - 16; const ivLocation = data.length - 32; const authTag = data.slice(authTagLocation); const iv = data.slice(ivLocation, authTagLocation); const encrypted = data.slice(0, ivLocation); const decipher = crypto.createDecipheriv(this._algorithm, this._fileKey, iv); decipher.setAuthTag(authTag); return resolve(Buffer.concat([decipher.update(encrypted), decipher.final()])); } resolve(data); }); stream.on('error', err => { reject(err); }); }); }
decoded = decipher.update(encryptedData, 'binary', 'utf8'); decoded += decipher.final('utf8'); const userInfo = JSON.parse(decoded);
var decrypt = function(text) { var decipher = crypto.createDecipher('aes-256-cbc','beamline') var dec = decipher.update(text,'hex','utf8') dec += decipher.final('utf8'); return dec; }
function decrypt(data) { // create decipher with set algo, secret and generated iv const decipher = crypto.createDecipher( process.env.CRYPTO_ALGO, process.env.CRYPTO_SECRET ); // deencrypt the passed in data const decrypted = decipher.update( data, process.env.CRYPTO_DIGEST, process.env.CRYPTO_OUT ); // return the decrypted message return `${decrypted}${deciper.final(process.env.CRYPTO_OUT)}`; }
function decrypt(text, key) { const textParts = text.split(DELIMITER); const iv = Buffer.from(textParts.shift(), HEX); const encryptedText = Buffer.from(textParts.join(DELIMITER), HEX); const decipher = crypto.createDecipheriv(ALGORITHM, Buffer.from(key), iv); let decrypted = decipher.update(encryptedText); decrypted = Buffer.concat([decrypted, decipher.final()]); return decrypted.toString(); }
export function decryptSettingsCache(data){ try{ let decipher = crypto.createDecipheriv("aes-256-cbc", Buffer.from(key[1], "base64"), Buffer.from(key[0], "base64")) let decrypted = decipher.update(Buffer.from(data, "base64")); decrypted = Buffer.concat([decrypted, decipher.final()]); return decrypted.toString("utf8") }catch(e){ return "{}" } }
decipher.setAuthTag(authTag); return resolve( Buffer.concat([decipher.update(encrypted), decipher.final()]) );
// method to decrypt data(password) function decrypt (password) { const decipher = crypto.createDecipher(algorithm, privateKey) let dec = decipher.update(password, 'hex', 'utf8') dec += decipher.final('utf8') return dec }
function aesDecrypt(encrypted, key) { const decipher = crypto.createDecipher('aes192', key); var decrypted = decipher.update(encrypted, 'hex', 'utf8'); decrypted += decipher.final('utf8'); return decrypted; }
/** * 路径解码 * @param path * @returns {*} */ function decode (path) { var decipher = crypto.createDecipher('aes192', secret); var dec = decipher.update(path, 'hex', 'utf8');//编码方式从hex转为utf-8; dec += decipher.final('utf8');//编码方式从utf-8; return dec }
//创建解密算法 function aesDecode(encrypted, key) { const decipher = crypto.createDecipher('aes192', key); var decrypted = decipher.update(encrypted, 'hex', 'utf8'); decrypted += decipher.final('utf8'); return decrypted; }
decryptText(text, password) { const decipher = crypto.createDecipher('aes192', password) let decrypted try { decrypted = decipher.update(text, 'hex', 'utf8') decrypted += decipher.final('utf8') } catch (e) { return false } return decrypted }
function decrypt(text){ var decipher = crypto.createDecipher(algorithm,password) var dec = decipher.update(text,'hex','utf8') dec += decipher.final('utf8'); return dec; }