Skip to content

Instantly share code, notes, and snippets.

@adamTrz
Created November 4, 2019 15:16
Show Gist options
  • Select an option

  • Save adamTrz/85a1591db9110b8a7d317c634a2b4f89 to your computer and use it in GitHub Desktop.

Select an option

Save adamTrz/85a1591db9110b8a7d317c634a2b4f89 to your computer and use it in GitHub Desktop.
const encrypt = (text: string) => {
const textBytes = aes.utils.utf8.toBytes(text);
const aesCtr = new aes.ModeOfOperation.ctr(aes256key);
const encryptedBytes = aesCtr.encrypt(textBytes);
const encryptedHex = aes.utils.hex.fromBytes(encryptedBytes);
return encryptedHex;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment