Created
February 19, 2018 09:50
-
-
Save axjs/3ded23c3edf522ea1c23f7a4d122e432 to your computer and use it in GitHub Desktop.
XOR crypt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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