Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Please help me (Javascript and AHK)


  • Please log in to reply
No replies to this topic
oldbrother
  • Members
  • 149 posts
  • Last active: Nov 09 2014 07:36 PM
  • Joined: 06 Jul 2005
Hello,

I found the encryption functions here (http://www.mvjantzen.com/blog/?p=1005) are very useful. they are simple and fast, but limited to a~z and A~Z. How can I enclose numbers (0~9 and dot) to them. I am new to Javascript.

Also, how to translate these functions to AHK?

Your help is highly appreciated!

function encodeStr(uncoded) {
uncoded = uncoded.toUpperCase().replace(/^\s+|\s+$/g,"");
var coded = "";
var chr;
for (var i = uncoded.length - 1; i >= 0; i--) {
chr = uncoded.charCodeAt(i);
coded += (chr >= 65 && chr <= 90) ?
	 key.charAt(chr - 65 + 26*Math.floor(Math.random()*2)) :
	 String.fromCharCode(chr);
}
return encodeURIComponent(coded);
}

function decodeStr(coded) {
coded = decodeURIComponent(coded);
var uncoded = "";
var chr;
for (var i = coded.length - 1; i >= 0; i--) {
chr = coded.charAt(i);
uncoded += (chr >= "a" && chr <= "z" || chr >= "A" && chr <= "Z") ?
	 String.fromCharCode(65 + key.indexOf(chr) % 26) :
	 chr;
}
return uncoded;
}