View Code? Open in Web Editor
NEW
[Library] Simplified Node.js Encryption, Hashing, and HMAC. Featuring security & policy by design to ensure strong standards for development of your services.
Home Page: https://www.npmjs.org/cryptocipher
License: MIT License
JavaScript 0.82%
TypeScript 98.55%
Shell 0.63%
cryptocipher's Introduction
cryptocipher's People
Contributors
Watchers
cryptocipher's Issues
Is your feature request related to a problem? Please describe.
No.
Describe the solution you'd like to see.
Fully working and verified implementation of HMAC wrapper with NodeJS per documentation specs.
Additional Context
https://nodejs.org/api/crypto.html#crypto_class_hmac
Is your feature request related to a problem? Please describe.
When JavaScript is attempting to parse the typings of CryptoCipher, it fails to find correct typings for functions that can return multiple types of classes.
Describe the solution you'd like to see.
Deprecate: fetch()
Implement: fetchCipher() fetchHasher() fetchHMAC() etc.
Is your feature request related to a problem? Please describe.
N/A
Describe the solution you'd like
Add better examples to the README
Describe alternatives you've considered
N/A
Additional context
const { getCipher } = require ( 'cryptocipher' )
async function main ( ) {
const driver = getCipher ( 'aes256' )
const encrypted = await driver . encrypt ( {
key : '12312312312312311231231231231231' ,
content : 'hello world'
} )
console . info ( encrypted )
/*
{
content: '&7MUiLET-k=MmFX]/e56ab59568c98460ee8812cc1a51477b',
aad: 'EUCH9&Px_@'
}
*/
const decrypted = await driver . decrypt ( {
key : '12312312312312311231231231231231' ,
content : encrypted . content ,
aad : encrypted . aad , // required if provided by encrypted
tag : encrypted . tag // required if provided by encrypted
} )
console . info ( decrypted )
/*
{
content: 'hello world'
}
*/
}
main ( )
const { getHasher } = require ( 'cryptocipher' )
async function main ( ) {
const driver = getHasher ( 'sha256' )
const digest_1 = await driver . digest ( {
content : 'hello world' ,
digest : 'hex' // or base64, latin1
} )
console . info ( digest_1 )
/*
{
content: 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9'
}
*/
const digest_2 = await driver . digest ( {
content : 'hello world' ,
digest : 'hex' , // or base64, latin1
iter : 300 // self iterate 300 times (passwords!)
} )
console . info ( digest_2 )
/*
{
content: 'd20ce3fe12c1b938ccd5346227cd5452cef7d345aff379300685f32ab56b753e'
}
*/
}
main ( )