1.0.2 • Published 5 years ago
unitiweb-crypter v1.0.2
unitiweb-crypter
This is a class that will encrypt, decrypt, and encode strings. Currently it uses cryptr
to handle the encryption.
How to use
Install Package
To install the package you would run this code
npm install unitiweb-crypter
Instantiate Class
Library for encrypting, decrypting and encoding strings.
// A random secret key
const secret = 'abc123def456(@%';
// Instantiate the class
const crypter = new Crypter(secret);
Using the Class
Here's how you use the class to encrypt, decrypt, and encode
// Setup the class
const secret = 'abc123def456(@%'
const crypter = new Crypter(secret)
// The string
const myString = 'This is a test'
// Encrypt a string
const myStringEncrypted = crypter.encode(myString)
// Decrypt a string
const myStringDecrypted = crypter.decrypt(myStringEncrypted)
// SHA256 encode a string
const encodedString = crypter.sha256(myString)