Need private packages and team management tools?Check out npm Teams »

x-digest

1.0.2 • Public • Published

Installation

npm install x-digest

Usage

const digest = require('x-digest')
const text = 'hello world! 你好,世界!'
const secret = 'i am a secret'
 
console.log('random =', digest.random(32))
console.log('md5 =', digest.md5(text))
console.log('sha1 =', digest.sha1(text))
console.log('hmac =', digest.hmac(text, secret))
 
const aesEncrypted = digest.aesEncrypt(text, secret)
console.log('aes encrypted =', aesEncrypted)
console.log('aes decrypted =', digest.aesDecrypt(aesEncrypted, secret))
 
const keyPair = digest.generateKeyPair(secret)
console.log(keyPair.publicKey)
console.log(keyPair.privateKey)
 
const encrypted = digest.publicEncrypt(text, keyPair.publicKey)
console.log('public encrypted =', encrypted)
console.log('private decrypted =', digest.privateDecrypt(encrypted, keyPair.privateKey, secret))

Install

npm i x-digest

DownloadsWeekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

6.85 kB

Total Files

3

Last publish

Collaborators

  • avatar