Skip to content

Instantly share code, notes, and snippets.

@widnyana
Created October 14, 2025 09:02
Show Gist options
  • Select an option

  • Save widnyana/1ace934049444661a0e112ccbeb963e8 to your computer and use it in GitHub Desktop.

Select an option

Save widnyana/1ace934049444661a0e112ccbeb963e8 to your computer and use it in GitHub Desktop.
encrypts and decrypts text using AES
export const encryptPayload = function(payload: string) {
const bytes = CryptoJS.AES.encrypt(payload, process.env.API_SECRET);
const value = bytes.toString();
return value;
}
export const decryptPayload = function(payload: string) {
const bytes = CryptoJS.AES.decrypt(payload, process.env.API_SECRET);
const originalValue = bytes.toString(CryptoJS.enc.Utf8);
return originalValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment