Skip to content

Instantly share code, notes, and snippets.

@Gamalalegende
Forked from jadeallencook/password-decrypt.js
Created November 15, 2022 16:25
Show Gist options
  • Save Gamalalegende/db85f27e3e7bf496f8a9385721e73702 to your computer and use it in GitHub Desktop.
Save Gamalalegende/db85f27e3e7bf496f8a9385721e73702 to your computer and use it in GitHub Desktop.
Password decryption for Hack This Site's basic level 6.
function decrypt(password) {
var letters = 'abcdefghijklmnopqrstuvwxyz',
decrypt = '';
for (var x = 0; x < password.length; x++) {
var value = password[x];
if (isNaN(value)) decrypt += letters[letters.indexOf(value) - x];
else decrypt += value - x;
}
return decrypt;
}
decrypt(['a', 5, 'h', 7, 7, 9, 'i', 'h']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment