You have to invert each operation and invert the order of the operations. I will give you a breakdown of every operation and leave it to you to actually do the inversion:
Preparation:
t = parseInt((+new Date()).toString().substr(11))
: it gets the the last two digits of the current UTC timestamp, aka the 100th and the 1000th of a second. The || 1
is just for error handling in case the Date does not give a useful result.
y = ('0' + t.toString(16)).substr(-2)
: convert the previous t
into base 16. The 0 prefix and -2 substring are once again just corner case error handling
Obfuscation:
a.split('').map(function(e, i) {
return String.fromCharCode(e.charCodeAt(0) + i % t);
}).join('')
: iterate over every char of the input string and apply the inner function:
- get the char code and add the index modulo
t
and get a String back from that char code
- pass the char transformed string into
obbtoa
:
btoa
the string
- replace different special characters
- the
y
is prepended to the result string so the decoding can know both the t
and y
.
To get an idea of the reversal:
- take the first two characters to get
y
, inverse the operation we used to compute y
from t
to get "our" t
- inverse the replacements, inverse the
btoa
- inverse the char transformation by basically doing a
-
instead of a +