Skip to content

Commit

Permalink
Base 8
Browse files Browse the repository at this point in the history
  • Loading branch information
ghluka committed Apr 28, 2024
1 parent eb7e590 commit 9fbf320
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions techdemos/encode/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const codes = {
encode: text => text.split("").map(c => c.charCodeAt(0).toString(10).padStart(3, "0")).join(" ").toUpperCase(),
decode: text => text.split(" ").filter(p => !!p).map(c => String.fromCharCode(parseInt(c, 10))).join("")
},
"Base8 (Octal)": {
encode: text => text.split("").map(c => c.charCodeAt(0).toString(8).padStart(3, "0")).join(" ").toUpperCase(),
decode: text => text.split(" ").filter(p => !!p).map(c => String.fromCharCode(parseInt(c, 8))).join("")
},
"Base2 (Binary)": {
encode: text => text.split("").map(c => c.charCodeAt(0).toString(2).padStart(8, "0")).join(" "),
decode: text => text.split(" ").filter(p => !!p).map(c => String.fromCharCode(parseInt(c, 2))).join("")
Expand Down

0 comments on commit 9fbf320

Please sign in to comment.