Created
March 16, 2015 13:16
-
-
Save skslater/63155d45d6edfd09b95e to your computer and use it in GitHub Desktop.
SAP Upgrade Key Generator
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
// generator.js | |
function generate() | |
{ | |
if (event.preventDefault) { | |
event.preventDefault(); } | |
else { | |
event.returnValue = false; } | |
var hexkey = [0, 0, 0, 0, 0]; | |
var sid = document.getElementsByName("sid")[0].value.toUpperCase(); | |
var host = document.getElementsByName("host")[0].value.toUpperCase(); | |
var sysnr = document.getElementsByName("sysnr")[0].value; | |
if (sid.length != 3) | |
{ | |
showError("SID must be 3 letters"); | |
return false; | |
} | |
if (host.length == 0) | |
{ | |
showError("Host cannot be blank"); | |
return false; | |
} | |
if ((sysnr.length == 0) || (sysnr.length > 2)) | |
{ | |
showError("System number must be 1-2 digits"); | |
return false; | |
} | |
var sidsys = sid + zeroPad(sysnr); | |
hostlen = host.length; | |
if ((hostlen > 0) && (hostlen < 5)) | |
{ | |
host = host + Array(6 - hostlen).join(" "); | |
} | |
if ((hostlen > 5) && (hostlen < 10)) | |
{ | |
host = host + Array(11 - hostlen).join(" "); | |
} | |
if ((hostlen > 10) && (hostlen < 15)) | |
{ | |
host = host + Array(16 - hostlen).join(" "); | |
} | |
if (host.length < 15) | |
{ | |
host = host + Array(16 - host.length).join('\0'); | |
} | |
for (i = 0; i < 5; i++) | |
{ | |
hexkey[i] = ((((0 ^ sidsys.charCodeAt(i)) ^ host.charCodeAt(i)) ^ host.charCodeAt(i + 5)) ^ host.charCodeAt(i + 10)); | |
} | |
hexkey[0] = ((hexkey[0] ^ 84) ^ 0); | |
hexkey[1] = ((hexkey[1] ^ 131) ^ 11); | |
hexkey[2] = ((hexkey[2] ^ 194) ^ 46); | |
hexkey[3] = ((hexkey[3] ^ 52) ^ 105); | |
hexkey[4] = ((hexkey[4] ^ 119) ^ 188); | |
strkey = "" + zeroPad(hexkey[0].toString(16).toUpperCase()) + zeroPad(hexkey[1].toString(16).toUpperCase()) + zeroPad(hexkey[2].toString(16).toUpperCase()) + zeroPad(hexkey[3].toString(16).toUpperCase()) + zeroPad(hexkey[4].toString(16).toUpperCase()); | |
showNotice("Your installation key is " + strkey); | |
return false; | |
} | |
function showError(text) | |
{ | |
var notice = document.getElementById("notice"); | |
notice.innerHTML = text; | |
notice.className = "error"; | |
} | |
function showNotice(text) | |
{ | |
var notice = document.getElementById("notice"); | |
notice.innerHTML = text; | |
notice.className = "notice"; | |
} | |
function zeroPad(n) | |
{ | |
return (n.length < 2) ? ("0" + n) : n; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment