openssl-file
v1.0.0
Published
A Javascript library for node, to enable it to encrypt and decrypt files in a openssl compatible way.
Downloads
7
Maintainers
Readme
node-openssl-file
A Javascript library for node, to enable it to encrypt and decrypt files in a openssl compatible way. Decryption is not yet implemented but shoud be very little work to add it. This libary uses the old way of generating the key from the password, which is now considered insecure, so only use this library for compatibility reasons. The key now should be generated with PBKDF2, if need more information, look into the node docs for crypto.pbkdf2 and crypto.createCipher.
Functions
EVP_BytesToKey (password: string|Buffer, salt: string|Buffer|null, keyLen: number, hashName: string = "SHA256", ivLen = 0)
This function works exactly like the same named openssl function: EVP_BytesToKey.
password
: a buffer or a string (which is converted to a buffer via ascii encoding, so do not use utf8 characters)salt
: a buffer or a string with byte length 8, if it is null no salt is usedkeyLen
: the length of the needed keyhashName
: the hash to be used for key generation, has to be supported by crypto.createHashivLen
: the length of the needed IV (initialization vector)- returns: {key: Buffer, iv: Buffer}
opensslEncBuf(algo: string, inp: Buffer, pw: string, useSalt: bool = true)
This function works like calling openssl {algo} -e -k {pw} -salt
.
algo
: is the encryption algorithm e.g.bf
(blowfish), must be supported by crypto.createCipherivinp
: is the data to be encryptedpw
: is the password to encrypt withuseSalt
: if you don't want to use a salt, pass false. This is like ommiting the-salt
parameter when calling openssl.- returns: A Buffer containing the encrypted data