How to use the createDecipher function from crypto

Find comprehensive JavaScript crypto.createDecipher code examples handpicked from public code repositorys.

244
245
246
247
248
249
250
251
252
253

* Decryption example using Decipher

```js
const crypto = require('crypto');  
const decipher = crypto.createDecipher('aes192', 'a password');  

const encrypted = '4ce3b761d58398aed30d5af898a0656a3174d9c7d7502e781e83cf6b9fb836d5';  
const decrypted = decipher.update(encrypted, 'hex', 'utf8');  
decrypted += decipher.final('utf8');  
fork icon932
star icon0
watch icon52

+ 3 other calls in file

178
179
180
181
182
183
184
185
186
187
  }
}

if (test.password) {
  if (common.hasFipsCrypto) {
    assert.throws(() => { crypto.createDecipher(test.algo, test.password); },
                  errMessages.FIPS);
  } else {
    const decrypt = crypto.createDecipher(test.algo, test.password, options);
    decrypt.setAuthTag(Buffer.from(test.tag, 'hex'));
fork icon42
star icon19
watch icon0

+ 9 other calls in file

204
205
206
207
208
209
210
211
212
213
  var decipher = crypto.createDecipheriv('aes-256-cbc', key, iv);
  decipher.setAutoPadding(true);
  return decipher.update(data, 'base64', 'utf8') + decipher.final('utf8');
};
exports.decryptOld = function (data, key) {
  var decipher = crypto.createDecipher('aes-256-cbc', key);
  decipher.setAutoPadding(true);
  return decipher.update(data, 'base64', 'utf8') + decipher.final('utf8');
};

fork icon12
star icon36
watch icon7

+ 2 other calls in file

62
63
64
65
66
67
68
69
70
71
 * @param {string} seed - A seed to use for the symmetric decryption.
 * @returns {string} The plaintext representation of the given encrypted text.
 */
module.exports.decryptTextSync = function (cryptText, seed) {
    try {
        var decipher = crypto.createDecipher('aes-128-cbc', seed);
        var dec = decipher.update(cryptText, 'hex', 'utf8');
        dec += decipher.final('utf8');
        return dec;
    } catch(err) {
fork icon3
star icon5
watch icon3

467
468
469
470
471
472
473
474
475
476
// to a ciphertext which will be in hex
let ciph = cipher.update(plaintext, 'utf8', 'hex');
// Only use binary or hex, not base64.
ciph += cipher.final('hex');

const decipher = crypto.createDecipher('aes192', key);
let txt = decipher.update(ciph, 'hex', 'utf8');
txt += decipher.final('utf8');

assert.strictEqual(txt, plaintext);
fork icon0
star icon0
watch icon0

+ 5 other calls in file

-1
exports.listCiphers = exports.getCiphers = crypto.getCiphers
fork icon0
star icon0
watch icon0

336
337
338
339
340
341
342
343
344
  cipher algorithms to use or exclude.

If no 'ca' details are given, Node.js will use Mozilla's default
[publicly trusted list of CAs][].

### crypto.createDecipher(algorithm, password)

Creates and returns a `Decipher` object that uses the given `algorithm` and
`password` (key).
fork icon0
star icon0
watch icon1