Skip to content

Instantly share code, notes, and snippets.

@Chandler
Created September 13, 2012 21:30
Show Gist options
  • Save Chandler/3717822 to your computer and use it in GitHub Desktop.
Save Chandler/3717822 to your computer and use it in GitHub Desktop.
$(".encrypted-content").show()
$(".encrypted-content").html(function(index, oldtext){
new_string = ""
/*handle special html characters */
oldtext = oldtext.replace(/>/g,">");
oldtext = oldtext.replace(/&lt;/g,"<");
oldtext = oldtext.replace(/&amp;/g,"&");
for ( var i = 0; i < oldtext.length; i++ )
{
code = oldtext.charCodeAt(i);
letter = oldtext.charAt(i);
if(code == 32){ /*skip spaces " " == 32 */
new_string += letter
}
else if (code >79){
new_string += String.fromCharCode(code - 47)
}
else{
new_string += String.fromCharCode(code + 47)
}
}
return new_string
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment