/gist:22770ec9f14d409e3ac7 Secret
Created
February 20, 2015 06:09
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
function BiSequence(binaries){ | |
this.BI_STR_LEN = 8; | |
this.binaries = binaries; | |
} | |
BiSequence.prototype.toString = function(binaries){ | |
var msg = ""; | |
var result = 0; | |
for(var i = 0; i < this.binaries.length; i++){ | |
for(var j = 0; j < this.BI_STR_LEN; j++){ | |
result = result * 2 + parseInt(this.binaries[i][[j]]); | |
} | |
msg += String.fromCharCode(result); | |
result = 0; | |
} | |
return msg; | |
} | |
function Main(){ | |
input = prompt("What is your number: "); | |
var regex = /(0|1){8}/g | |
var sequence = new BiSequence(input.match(regex)); | |
confirm(sequence.toString()); | |
} | |
Main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment