|
最終的なエンコードコード(^ 2 に修正) |
|
javascript |
|
コードをコピーする |
|
let str = "https://x.gd"; |
|
|
|
|
|
let encoded = str |
|
.split("") |
|
.map((char, ind) => { |
|
|
|
if (ind % 2 !== 0) { |
|
return String.fromCharCode(char.charCodeAt() ^ 2); |
|
} |
|
return char; |
|
}) |
|
.join(""); |
|
|
|
|
|
encoded = encodeURIComponent(encoded); |
|
|
|
console.log(encoded); |
|
最終的なデコードコード |
|
javascript |
|
コードをコピーする |
|
function decode(encodedStr) { |
|
|
|
let decodedStr = decodeURIComponent(encodedStr); |
|
|
|
|
|
return decodedStr |
|
.split("") |
|
.map((char, ind) => { |
|
|
|
if (ind % 2 !== 0) { |
|
return String.fromCharCode(char.charCodeAt() ^ 2); |
|
} |
|
|
|
return char; |
|
}) |
|
.join(""); |
|
} |
|
|
|
|
|
let encoded = "hvtrs8%2F-x%2Cgf%2F"; |
|
console.log(decode(encoded)); |