diff --git a/tools/encoder/index.js b/tools/encoder/index.js index 1fc413e..49e8863 100644 --- a/tools/encoder/index.js +++ b/tools/encoder/index.js @@ -1,6 +1,3 @@ - - - //Copies the text from the output function docopy() { document.getElementById("output").select(); @@ -9,13 +6,17 @@ function docopy() { function doencode() { var inputData = document.getElementById("input").value; - var outputdata = rot13(inputData); + var outputdataP1 = rot13(inputData); + var outputdataP2 = base64Encode(outputdataP1); + var outputdata = outputdataP2; document.getElementById("output").value = outputdata; } function dodecode() { var inputData = document.getElementById("input").value; - var outputdata = rot13(inputData); + var outputdataP1 = rot13(inputData); + var outputdataP2 = base64Decode(outputdataP1); + var outputdata = outputdataP2; document.getElementById("output").value = outputdata; } @@ -23,3 +24,11 @@ function dodecode() { function rot13(message) { return message.replace(/[a-z]/gi, letter => String.fromCharCode(letter.charCodeAt(0) + (letter.toLowerCase() <= 'm' ? 13 : -13))); } + +function base64Encode(message) { + return btoa(message); +} + +function base64Decode(message) { + return atob(message); +} \ No newline at end of file