Password hacking

How to hack password java code

How to hack password java code


var charset = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
function crack(value){
    function toRadix(N,radix) {
        var HexN = "", 
            Q = Math.floor(Math.abs(N)), 
            R,
            strv = charset,
            radix = strv.length;
        while (true) {
            R = Q % radix;
            HexN = strv.charAt(R) + HexN;
            Q = (Q - R) / radix; 
            if (Q == 0) 
                break;
        };
        return ((N < 0) ? "-" + HexN : HexN);
    };
    var start = (new Date()) * 1,
        cracked = false,
        index = 0;
    while(!cracked){
        if(toRadix(index) == value)
            cracked = true;
        else
            index++;
    };
    alert(((new Date()) * 1) - start);
};

This script works fine, but it is slow.

What would be the best way to speed up this algorithm?

I see a minor speed-up already.

while (true) {
    R = Q % radix;
    HexN = strv.charAt(R) + HexN;
    Q = (Q - R) / radix; 
    if (Q == 0) 
        break;
};

When you have a while(true){blah blah if(condition) break;}, you really have this:

do {
   blah blah
} while (!condition);

And that’s what I’d suggest to you too.

do {
    R = Q % radix;
    HexN = strv.charAt(R) + HexN;
    Q = (Q - R) / radix; 
} while (Q != 0);

You can apply the same idea here:

var start = (new Date()) * 1,
        cracked = false,
        index = 0;
    while(!cracked){
        if(toRadix(index) == value)
            cracked = true;
        else
            index++;
    };

to

var start = (new Date()) * 1,
        cracked = false,
        index = -1;
    do {
        index++;
    } while(toRadix(index) != value);

And remove the whole cracked variable.

var start = (new Date()) * 1,
        index = -1;
    do {
        index++;
    } while(toRadix(index) != value);

For the bigger performance gains it might be better to look for algorithmic optimization, rather than optimization of the implementation.

What Is Ethical Hacking?

submit questions and problems

Leave a Reply

Your email address will not be published. Required fields are marked *