Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js - Set padding in crypto module

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?

like image 562
dsw88 Avatar asked Sep 23 '13 23:09

dsw88


1 Answers

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).

like image 137
Nitzan Shaked Avatar answered Oct 06 '22 00:10

Nitzan Shaked