Skip to content

Instantly share code, notes, and snippets.

View timeturnback's full-sized avatar

LongTran timeturnback

  • Lotte ECommerce, Tappo, Gigacover
View GitHub Profile
@timeturnback
timeturnback / aes.js
Created July 29, 2023 13:52
AES CFB 256 encrypt and decrypt text
import CryptoJS from 'crypto-js';
export function encryptText(keyStr, text) {
const private_key = CryptoJS.SHA256(keyStr).toString(CryptoJS.enc.Latin1);
const rem = text.length % 16;
const padded = CryptoJS.enc.Latin1.parse(text.padEnd(text.length + (16 - rem), '\0'));
const iv = CryptoJS.lib.WordArray.random(16);
const cipher = CryptoJS.AES.encrypt(padded, CryptoJS.enc.Latin1.parse(private_key), {
iv: iv,
mode: CryptoJS.mode.CFB,

Keybase proof

I hereby claim:

  • I am timeturnback on github.
  • I am timeturnback (https://keybase.io/timeturnback) on keybase.
  • I have a public key ASBqe9QuUiDy9mlxuZzcJddU7szqa2etRiUDOYoSttXrtgo

To claim this, I am signing this object: