Created
March 18, 2018 09:28
-
-
Save JugurthaK/eea8155f5abc05cc21426f8ef1216b70 to your computer and use it in GitHub Desktop.
Lire une phrase encodée, peu importe la base
This file contains hidden or 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
var decode = function (phrase, base){ | |
// On met en binaire si il n'y a pas eu de base spécifiée | |
if (base === undefined){ | |
base = 2; | |
} | |
var phraseEncodee = phrase.split (" "); | |
var phraseFinale; | |
for (var i = 0 ; i < phraseEncodee.length; i++){ | |
var char = phraseEncodee[i]; | |
var char = parseInt(char, base); | |
phraseFinale += String.fromCharCode(char); | |
} | |
// J'ai pas eu le courage de finaliser avec une interface graphique :( | |
console.log(phraseFinale); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment