MCPcopy
hub / github.com/Unitech/pm2 / decipherMessage

Method decipherMessage

modules/pm2-io-agent/src/Utility.js:281–291  ·  view source on GitHub ↗

* Decipher data using 256 bits key (AES) * @param {Hex} data input data * @param {String} key 256 bits key * @return {Object} deciphered data parsed as json object

(msg, key)

Source from the content-addressed store, hash-verified

279 * @return {Object} deciphered data parsed as json object
280 */
281 static decipherMessage (msg, key) {
282 try {
283 let decipher = crypto.createDecipher(Cipher.CIPHER_ALGORITHM, key)
284 let decipheredMessage = decipher.update(msg, 'hex', 'utf8')
285 decipheredMessage += decipher.final('utf8')
286 return JSON.parse(decipheredMessage)
287 } catch (err) {
288 console.error(err)
289 return null
290 }
291 }
292
293 /**
294 * Cipher data using 256 bits key (AES)

Callers

nothing calls this directly

Calls 3

updateMethod · 0.65
finalMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected