Skip to content

Instantly share code, notes, and snippets.

@PeterTheOne
PeterTheOne / script.js
Last active December 24, 2015 04:29
Brute force mistyped GPG passwords. script.js creates a list of possible passwords by scrambling a string by switching the positions of two neighboring characters, script.sh tries them.
// http://stackoverflow.com/a/1431113/782920
String.prototype.replaceAt=function(index, character) {
return this.substr(0, index) + character + this.substr(index + character.length);
}
function scramble(text) {
var result = text + '\n';
for (var i = 0; i < text.length -1; i++) {
var temp = text;
temp = temp.replaceAt(i, text.charAt(i + 1));
temp = temp.replaceAt(i + 1, text.charAt(i));