Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Nodejs encryption with CTR
const crypto = require('crypto')
class Crypto {
constructor () {
this.algorithm = 'aes192'
this.secret = 'd6F3Efeq'
encrypt (text) {
let cipher = crypto.createCipher(this.algorithm, this.secret)
let crypted = cipher.update(text, 'utf8', 'hex')
crypted +='hex')
return crypted
decrypt (text) {
let decipher = crypto.createDecipher(this.algorithm, this.secret)
let dec = decipher.update(text, 'hex', 'utf8')
dec +='utf8')
return dec
const c = module.exports = new Crypto()
// DEMO:
let enc = c.encrypt('Hello')
let dec = c.decrypt(enc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.