Usage
When using this, you must give credit, as this is under a Creative Commons License (see sidebar for more information)Notes
- Does not retain capitalization or punctuation
- Spaces are replaced with a '<space>' Sub-string after the initial encoding. You would have to replace this manually if you don't like it.
Try it out!
String:
Offset:
Offset:
Code
- /*
- ccccc ooooo dddd eeeee
- C O O D D E
- C O O D D Eee
- C O O D D E
- ccccc ooooo dddd eeeee
- Copyright 2014 Conor O'Brien under a Creative Commons Attribution 4.0 International License.
- */
- var alphabet = {
- lower: ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],
- upper: ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],
- number: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]
- }
- String.prototype.encode = function(){
- var str = this.valueOf();
- var returnStr = [];
- var notAny = false;
- str = str.toLowerCase()
- str = str.split("")
- for(i = 0; i < str.length; i++){
- for(h = 0; h < alphabet.lower.length; h++){
- if(str[i]==alphabet.lower[h]){
- returnStr.push(h+1)
- } else {
- notAny = true;
- }
- }
- if(str[i]==" "){
- returnStr.push("<space>")
- } else if(!notAny){
- returnStr.push(str[i])
- }
- notAny = false;
- }
- returnStr = returnStr.toString();
- while (returnStr.search(",") !== -1){
- returnStr = returnStr.replace(","," ");
- }
- return returnStr;
- }
- String.prototype.scramble = function(number){
- var str = this.valueOf();
- var returnStr = [];
- var notAny = false;
- str = str.toLowerCase()
- str = str.split(" ")
- for(i = 0; i < str.length; i++){
- for(h = 0; h < alphabet.number.length; h++){
- if(str[i]==alphabet.number[h]){
- returnStr.push(alphabet.number[h] + number)
- }
- }
- }
- returnStr = returnStr.toString();
- while (returnStr.search(",") !== -1){
- returnStr = returnStr.replace(","," ");
- }
- return returnStr;
- }
- String.prototype.decode = function(){
- var str = this.valueOf();
- var returnStr = [];
- str = str.toLowerCase()
- str = str.split(" ")
- for(i = 0; i < str.length; i++){
- for(h = 0; h < alphabet.number.length; h++){
- if(str[i]==alphabet.number[h]){
- returnStr.push(alphabet.lower[h])
- }
- }
- if (str[i]=="<space>"){
- returnStr.push(" ");
- }
- }
- returnStr = returnStr.toString();
- while (returnStr.search(",") !== -1){
- returnStr = returnStr.replace(",","");
- }
- return returnStr;
- }
OOOOh My Gawd! this stuff amaaaaazes me! lol i do not understand much of it but i always find myself here lost for "hours" �� in the depths of all sorts of pages (("behind the scenes" if you will)) ahaha! �� i "LOVE THIS STUFF"! an really wish i could learn it more thoroughly! =) for now. . . ? i'll just play around to learn and try not to screw anything UP!
ReplyDelete{ ●_●`} lmao! 10?! (1:00a)
That's great! ^^ Thanks for the comment, I appreciate that. If you want to learn more of code, I would suggest following https://developer.mozilla.org/en-US/docs/Web/JavaScript/ for a wiki on JavaScript--it's how I learned, so it should be O.K.!
Delete