On May 30, 2012, at 6:16 PM, jing yang wrote:

> I was testing the hash methods on a 16 bytes input, randomly generated
> with the SecureRandom class.

I'm still getting far more faster speeds on SGS2, around 4871ms for 524288 
iterations. Roughly half of the time is spent generating random bytes, half 
calculating hash. My test code as below;

MessageDigest md = null;
SecureRandom sr = null;
try {
        MessageDigest md = MessageDigest.getInstance("SHA-256");
        SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");

        byte seed[] = sr.generateSeed(128);
        sr.setSeed(seed);

        final long LOOP = 524288;
        byte buf[] = new byte[16];

        long time = SystemClock.uptimeMillis();
        for (int i = 0; i < LOOP; ++i) {
                sr.nextBytes(buf);
                md.update(buf);
        }
        byte[] f = md.digest();
        Log.d("timing", "time=" + (SystemClock.uptimeMillis() - time));
} catch (Exception ex) {
        ex.printStackTrace();
}

--
H

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to