Skip to content

Instantly share code, notes, and snippets.

@caracal7
Forked from axjs/xor.js
Created March 13, 2019 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caracal7/362cfc12d159a89366d84c8a0db2475b to your computer and use it in GitHub Desktop.
Save caracal7/362cfc12d159a89366d84c8a0db2475b to your computer and use it in GitHub Desktop.
XOR crypt
const encrypt = (str, key) => str
.split('')
.map(s=>(s.charCodeAt()^key).toString(16))
.join('g')
;
const decrypt = (str, key) => str
.split('g')
.filter(Boolean)
.map(s=> String.fromCharCode(parseInt(s,16)^key) )
.join('')
;
let text = 'Текст для шифрования with english symbols',
key = 889360895;
let hash = encrypt(text, key);
//350295ddg350295cag350295c5g350295beg350295bdg350291dfg350295cbg350295c4g350295b0g350291dfg350295b7g350295c7g350295bbg350295bfg350295c1g350295cdg350295cfg350295c2g350295c7g350295b0g350291dfg35029188g35029196g3502918bg35029197g350291dfg3502919ag35029191g35029198g35029193g35029196g3502918cg35029197g350291dfg3502918cg35029186g35029192g3502919dg35029190g35029193g3502918c
decrypt(hash, key);
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment