You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
676 B
23 lines
676 B
'use strict';
|
|
var crypto = require('crypto');
|
|
var ECIES = require('./common/ECIES');
|
|
|
|
ECIES.symmetricEncrypt = function(key, iv, message) {
|
|
var cipheriv = crypto.createCipheriv('AES-256-CBC', key, iv);
|
|
var a = cipheriv.update(message);
|
|
var b = cipheriv.final();
|
|
var r = Buffer.concat([iv, a, b]);
|
|
return r;
|
|
};
|
|
|
|
ECIES.symmetricDecrypt = function(key, encrypted) {
|
|
var iv = encrypted.slice(0, 16);
|
|
var decipheriv = crypto.createDecipheriv('AES-256-CBC', key, iv);
|
|
var todecrypt = encrypted.slice(16, encrypted.length);
|
|
var a = decipheriv.update(todecrypt);
|
|
var b = decipheriv.final();
|
|
var r = Buffer.concat([a, b]);
|
|
return r;
|
|
};
|
|
|
|
module.exports = ECIES;
|
|
|