Permalink
Browse files

[fix] runtime: Crypto function since node 0.10.3

  • Loading branch information...
1 parent b2a8e8c commit 29948a3c87b07d46b9cc8a3ba5d5771200e6ac88 RG committed Apr 12, 2013
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/plugins/crypto/bslCrypto.nodejs
@@ -191,10 +191,10 @@ function rsa_decrypt(key, msg) {
*/
function cipher_encrypt(algorithm, password, data) {
try {
- var cipher = Crypto.createCipher(algorithm,buffer_of_binary(password));
- var crypted = cipher.update(buffer_of_binary(data),'binary','hex');
+ var cipher = Crypto.createCipher(algorithm, buffer_of_binary(password));
+ var crypted = cipher.update(buffer_of_binary(data),'hex');
crypted += cipher.final('hex');
- return binary_of_buffer(new Buffer(crypted));
+ return binary_of_buffer(new Buffer(crypted, 'hex'));
} catch(e) { console.log(e); return null }
}
@@ -203,9 +203,9 @@ function cipher_encrypt(algorithm, password, data) {
*/
function cipher_decrypt(algorithm, password, data) {
try {
- var decipher = Crypto.createDecipher(algorithm,buffer_of_binary(password));
- var dec = decipher.update(buffer_of_binary(data),'hex','binary');
- dec += decipher.final('utf8');
+ var decipher = Crypto.createDecipher(algorithm, buffer_of_binary(password));
+ var dec = decipher.update(buffer_of_binary(data));
+ dec += decipher.final();
return binary_of_buffer(new Buffer(dec));
} catch(e) { console.log(e); return null }
-}
+}

0 comments on commit 29948a3

Please sign in to comment.