Skip to content

Instantly share code, notes, and snippets.

@nainemom
Last active December 7, 2020 18:35
Show Gist options
  • Save nainemom/09720dc0c90cc6777d220d376124b9a8 to your computer and use it in GitHub Desktop.
Save nainemom/09720dc0c90cc6777d220d376124b9a8 to your computer and use it in GitHub Desktop.
Very simple Javascript string encode and decoder
function encoder(str, numericPass = 1234, decode = false) {
return str.split('').map(c => String.fromCharCode((c.charCodeAt(0) + ((decode ? -1 : 1) * numericPass)) % 256)).join('')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment