Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function crypt(input) {
  2.     var output = [];
  3.     var charCode;
  4.     for (var i = 0; i < input.length; i++) {
  5.         charCode = input.charCodeAt(i) ^ key[i % key.length].charCodeAt(0);
  6.  
  7.     output.push(String.fromCharCode(charCode));
  8.     }
  9.     return output.join("");
  10. }
  11.  
  12. const key = 'randomeky';
  13.  
  14. const encryted = crypt('raz dwa trzy', key);
  15. console.log('encrypted', encryted);
  16. const decrypted = crypt(encryted, key);
  17. console.log('decrypted', decrypted);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement