Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
@emartech/easy-crypto
Advanced tools
Provides simple wrappers around Node's crypto implementation.
To get started just require the lib and create an instance right away.
let crypto = require('crypto');
let ecrypto = require('@emartech/easy-crypto')();
let password = crypto.randomBytes(24).toString('hex');
let randomData = crypto.randomBytes(1024).toString('hex');
let encrypted = yield ecrypto.encryptAsync(password, randomData);
let decrypted = yield ecrypto.decryptAsync(password, encrypted);
randomData === decrypted; // true
There aren't too many options you can change and that is on purpose. This small wrapper library is secure by default. You can change two configurations: passwordSaltSize
, iterationCount
by passing them to the initialization function as follows:
let ecrypto = require('easy-crypto')(12, 10000); // parameters are in order: passwordSaltSize, iterationCount
The default value for passwordSaltSize
is 12 bytes
, for iterationCount
it is 10k iterations
.
passwordSaltSize
The size of the random data used to generate the encryption key. This value is in bytes
.
iterationCount
The iteration count used to generate the encryption key.
password
, plaintext
) -> ciphertext
password
should be any normal string. It will be used to generate the encryption key. plaintext
must be utf-8
encoded string. It will be "converted" to bytes
and those will be used for the cryptographic operations. The output of this operations is base64
encoded buffers. This will be used as the input of the decryptAsync
operation.
password
, ciphertext
) -> plaintext
password
should be any normal string. It will be used to generate the encryption key. ciphertext
must be the output of the encryptAsync
method. The library is not compatible with any other encryption library out of the box! The output of this operation is the original utf-8
encoded string.
The library is only a thin wrapper of node's own crypto
module. It uses well known and battle tested encryption techniques. It provides a convenient wrapper around these functions, taking away the details of using encryption correctly. Feel free to explore the source!
passwordSaltSize
random bytes
are used to create the 256 bit
long encryption key from the password
using pbkdf2
and the given iteration count
plaintext
is encrypted using aes-256-gcm
with the generated key and a 12 bytes
long random initialization vector
, this operation also yields a 16 bytes
long authentication tag
, which can be used to verify the encrypted data's integritypasswordSalt bytes
, initialization vector bytes
, ciphertext bytes
, authentication tag bytes
base64
and returns itbase64
input to bytespasswordSalt bytes
, initialization vector bytes
, ciphertext bytes
, authentication tag bytes
passwordSalt bytes
and the password
are used to generate the 256 bit
long encryption key using pbkdf2
and the given iteration count
ciphertext bytes
are decrypted using aes-256-gcm
with the generated key the initialization vector bytes
. During encryption the integrity of the date is also verified using the authentication tag bytes
utf-8
and returns itPlease find us, we would love your feedback!
FAQs
Provides simple wrappers around Node's crypto implementation.
The npm package @emartech/easy-crypto receives a total of 229 weekly downloads. As such, @emartech/easy-crypto popularity was classified as not popular.
We found that @emartech/easy-crypto demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 153 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.