Last active
July 17, 2019 14:04
-
-
Save Sarverott/cc4ae8d354029c2c0f53a9e5727a1fe1 to your computer and use it in GitHub Desktop.
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
/* | |
Sett Sarverott | |
***~~~~~~~~*** | |
plt tlp crypto functions | |
*/ | |
class fibonacci{ | |
constructor(){ | |
this.last=1; | |
this.beforeLast=1; | |
} | |
next(){ | |
var tmp=this.last; | |
this.last+=this.beforeLast; | |
this.beforeLast=tmp; | |
} | |
} | |
/* | |
{ | |
next:function(){ | |
var tmp=this.last; | |
this.last+=this.beforeLast; | |
this.beforeLast=tmp; | |
}, | |
last:1, | |
beforeLast:1 | |
} | |
*/ | |
function purpleLightTimekeeper(data, key){ | |
//console.log(data); | |
var fib=new fibonacci(); | |
var encoded=""; | |
for(var i=0;i<data.length;i++){ | |
//console.log(data.charCodeAt[i]-key.charCodeAt[fib.last%key.length]); | |
var tmp=data.charCodeAt(i)-key.charCodeAt(fib.last%key.length); | |
(tmp<0)?tmp+=256:true; | |
encoded+=String.fromCharCode(tmp); | |
fib.next(); | |
} | |
return encoded; | |
} | |
function timekeepLightPurpler(data, key){ | |
var fib=new fibonacci(); | |
var decoded=""; | |
for(var i=0;i<data.length;i++){ | |
var tmp=data.charCodeAt(i)+key.charCodeAt(fib.last%key.length); | |
(tmp>255)?tmp-=256:true; | |
decoded+=String.fromCharCode(tmp); | |
fib.next() | |
} | |
return decoded; | |
} | |
//CONSTRUCT 2 version | |
//decode | |
//Browser.ExecJS("var data='"&Function.Param(0)&"', key='"&Function.Param(1)&"';/*SARVEROTT*/var fib={next:function(){var tmp=this.last;this.last+=this.beforeLast;this.beforeLast=tmp;},last:1,beforeLast:1};var decoded="";for(var i=0;i<data.length;i++){var tmp=data.charCodeAt(i)+key.charCodeAt(fib.last%key.length);(tmp>255)?tmp-=256:true;decoded+=String.fromCharCode(tmp);fib.next()}return decoded;") | |
//encode | |
//Browser.ExecJS("var data='"&Function.Param(0)&"', key='"&Function.Param(1)&"';/*SARVEROTT*/var fib={next:function(){var tmp=this.last;this.last+=this.beforeLast;this.beforeLast=tmp;},last:1,beforeLast:1};var encoded='';for(var i=0;i<data.length;i++){var tmp=data.charCodeAt(i)-key.charCodeAt(fib.last%key.length);(tmp<0)?tmp+=256:true;encoded+=String.fromCharCode(tmp);fib.next();}return encoded;") | |
//EXAMPLE BEGINE | |
/* | |
console.log("~ZEGARMISTRZ SWIATLA PURPUROWY~"); | |
console.log(" example of usage"); | |
console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | |
var cryptoKey="ZEGARMISTRZ SWIATLA PURPUROWY"; | |
var messages=[ | |
"And when finally there will come for me", | |
"Purple light's watchmaker", | |
"To stir blue in my head", | |
"I will be bright and ready" | |
]; | |
console.log("our key is : "+cryptoKey); | |
console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | |
for(var i in messages){ | |
console.log("orginal : "+messages[i]); | |
console.log(messages); | |
console.log("crypted by tlp : "+timekeepLightPurpler(messages[i], cryptoKey)); | |
console.log(i); | |
console.log("crypted by plt : "+purpleLightTimekeeper(messages[i], cryptoKey)); | |
console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | |
} | |
var msgTmp="qwertyuiop"; | |
cryptoKey="1234567890"; | |
console.log("message: "+msgTmp); | |
msgTmp=timekeepLightPurpler(msgTmp, cryptoKey); | |
console.log("encrypting message with TLP using key \""+cryptoKey+"\""); | |
console.log("message: "+msgTmp); | |
msgTmp=purpleLightTimekeeper(msgTmp, cryptoKey); | |
console.log("decrypting message with PLT using key \""+cryptoKey+"\""); | |
console.log("message: "+msgTmp); | |
console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | |
*/ | |
//EXAMPLE END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment