This is a class that will encrypt, decrypt, and encode strings. Currently it uses cryptr
to handle the encryption.
To install the package you would run this code
npm install unitiweb-crypter
Library for encrypting, decrypting and encoding strings.
// A random secret key
const secret = 'abc123def456(@%';
// Instantiate the class
const crypter = new Crypter(secret);
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)