I was testing the hash methods on a 16 bytes input, randomly generated with the SecureRandom class. and sorry for the messy table. here is a tidier version.
Hash Based SHA256 SHA1 MD5 SHA512 No. of hashes Maximum Time taken (ms) 1,024 250 229 213 283 2,048 506 465 443 597 4,096 998 925 869 1142 8,192 1993 1839 1801 2254 16,384 3977 3703 3658 4528 32,768 7933 7281 7234 8990 65,536 15934 14846 14723 18216 131,072 32105 29696 29325 36466 262,144 64314 59278 58279 73158 524,288 128484 119484 116894 146227 1,048,576 254778 237204 233112 294316 2,097,152 524359 473092 466695 582703 On May 30, 8:48 pm, Harri Smått <[email protected]> wrote: > On May 30, 2012, at 5:56 AM, jing yang wrote: > > > 21 2,097,152 524359 473092 466695 582703 > > This doesn't seem right AFAIK. I ran SHA-256 for 2048000 char array 20 times > and it takes me 1920ms. I'm running this on SGS2 but the difference compared > to 524359ms just doesn't seem right. > > StringWriter sw = new StringWriter(); > for (int i = 0; i < 2048000; ++i) { > sw.append('a');} > > String str = sw.toString(); > > long time = SystemClock.uptimeMillis(); > for (int i = 0; i < 20; ++i) { > try { > MessageDigest md = MessageDigest.getInstance("SHA-256"); > md.update(str.getBytes()); > byte[] f = md.digest(); > } catch (Exception ex) { > ex.printStackTrace(); > }} > > Log.d("timing", "time=" + (SystemClock.uptimeMillis() - time)); > > -- > 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

