How to encrypt in node.js and decrypt using RNCryptor

I'm having problems encrypting data with node and decrypting with RNCryptor. As far as I understand, RNCryptor uses a special data format?

Cryptotext is generated as follows:

var crypto = require('crypto');
var cipher = crypto.createCipher('aes-256-cbc','InmbuvP6Z8');
var text = "123|123123123123123";
var crypted = cipher.update(text,'utf8','base64');
crypted += cipher.final('base64');

And I will decrypt as follows:

[RNDecryptor decryptData:plainText withPassword:password error:&error];

How am I supposed to do this? When I try to decrypt now, I get an empty NSData and no errors.

+4
source share
2 answers

Yes, RNCryptor displays encrypted data in its own format. If you create this format in your own encryption code (and use the same encryption settings), you can pass it to JNCryptor for decryption.

RNCryptor 3 34 :

  • byte [0] - (3).
  • byte [1] , (1 , 0 ).
  • [2-9] .
  • bytes [10-17] HMAC.
  • [18-33] IV.

.

32 (SHA256) HMAC .

: https://github.com/RNCryptor/RNCryptor-Spec/blob/master/RNCryptor-Spec-v3.md

0

RNCryptor - , , "", , , iv. , .

RNCryptor . commoncrypto, , Swift ( ), Common Crypto Objective-C . . SO , , .

0

All Articles