Question

I've been looking over the docs for the crypto module in Node, and I'm trying to figure out how to set the padding when doing symmetric encryption. I'm trying to use AES-128-ECB, with PKCS5 padding.

I can't see anywhere that it allows you to specify padding. I would certainly hope this is possible to do using this library. How can I specify padding for symmetric encryption in the crypto module?

Was it helpful?

Solution

http://nodejs.org/api/crypto.html#crypto_cipher_setautopadding_auto_padding_true

When you disable auto-padding, you can write any padding you wish by simply writing to cipher (which is a stream).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top