var tiny = {}; tiny.encrypt = (message,key)=>btoa([...message].reduce((a,c,i)=>a+tiny.xor(c,key,i),'')); tiny.decrypt = (encrypted,key)=>[...atob(encrypted)].reduce((a,e,i)=>a+tiny.xor(e,key,i),''); tiny.code = (v,i)=>(i!==undefined && (v=v[i]),v.charCodeAt(0)); tiny.char = v=>String.fromCharCode(v); tiny.xor = (c,key,i)=>tiny.char(tiny.code(c)^tiny.code(key,i%key.length)); var encrypted = tiny.encrypt('helloworld','sky')