Skip to content

Instantly share code, notes, and snippets.

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

  • Save adamTrz/620be660fab38e3b3d7574226ee1a261 to your computer and use it in GitHub Desktop.

Select an option

Save adamTrz/620be660fab38e3b3d7574226ee1a261 to your computer and use it in GitHub Desktop.
export const encryptXOR = (text: string, key: string) => {
const bytes = utf8.encode(text);
const output = [];
for (let i = 0; i < bytes.length; i++) {
output[i] = String.fromCharCode(
bytes[i].charCodeAt(0) ^ key[i % key.length].charCodeAt(0)
);
}
return base64.encode(output.join(''));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment