Snack-X / rijndael-js

Pure JS implementation of Rijndael algorithm
MIT License
18 stars 10 forks source link

decrypt Buffer direct #4

Closed bag7dad closed 4 years ago

bag7dad commented 4 years ago

var buf = Buffer.from(cipher.decrypt("string ..", 256, iv));

I already have Buffer encrypt with C# need to decrypt it must add method for direct buffer decrypt not String

Snack-X commented 4 years ago

I don't understand your question. I suppose you are asking about how to decrypt Buffer data.

You can use Buffer directly on this library.

> key = 'abcdefghijklmnop'                                                                                                                                       'abcdefghijklmnop'
> cipher = new Rijndael(key, 'ecb')

> enc
<Buffer 2a ac cd 80 83 ee 04 81 bc 15 38 f6 b1 23 a1 75 3f cb da 61 2d 4a 31 e5 5b d1 61 36 f1 fd 93 c4>
> dec = cipher.decrypt(enc, 256)
[
  48, 49, 50, 51, 52, 53, 54, 55, 56,
  57,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0
]