{"id":1928,"date":"2010-05-21T01:25:18","date_gmt":"2010-05-21T05:25:18","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=1928"},"modified":"2010-05-21T01:25:18","modified_gmt":"2010-05-21T05:25:18","slug":"droid-vs-nexus-1-who-can-calculate-md5-faster","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/droid-vs-nexus-1-who-can-calculate-md5-faster\/","title":{"rendered":"Droid vs Nexus 1: Who can calculate MD5 faster?"},"content":{"rendered":"<p>Nexus 1 indeed.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/farm4.static.flickr.com\/3399\/4619137368_6ddd6c29cc_o.png?w=640\" \/><br \/>\n17 files get their MD5 calculated on the Droid<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/farm5.static.flickr.com\/4068\/4619137390_359c4da1e5_o.png?w=640\" \/><br \/>\nand 17 files get their MD5 hash calculated on the Nexus 1<\/p>\n<p>Nexus 1 pwns.<\/p>\n<p>Here&#8217;s the code in case you&#8217;re curious.<br \/>\n[java]<br \/>\n\tpublic void onClick(View v) {<br \/>\n                                _logTextView.setText(&quot;MD5 Benchmark on &quot; + Build.DEVICE + &quot;nn&quot;);<br \/>\n\t\t\t\tif (GlobalVariables.APP_CONTEXT == null)<br \/>\n\t\t\t\t\tGlobalVariables.APP_CONTEXT = getApplicationContext();<\/p>\n<p>\t\t\t\tList&lt;FileDescriptor&gt; sharedAudioFiles = Engine.INSTANCE.LIBRARIAN.getSharedAudioFiles(0, 17);<br \/>\n\t\t\t\tfor (FileDescriptor fs: sharedAudioFiles) {<br \/>\n\t\t\t\t\tlong start = 0;<br \/>\n\t\t\t\t\tString md5 = null;<br \/>\n\t\t\t\t\tlong length = 0;<br \/>\n\t\t\t\t\ttry {<br \/>\n\t\t\t\t\t\tstart = System.currentTimeMillis();<br \/>\n\t\t\t\t\t\tFile f = new File(fs.path);<br \/>\n\t\t\t\t\t\tlength = f.length();<br \/>\n\t\t\t\t\t\tmd5 = FrostWireUtils.getMD5(f);<\/p>\n<p>\t\t\t\t\t} catch (Exception e) { }<br \/>\n\t\t\t\t\tlong time = System.currentTimeMillis() &#8211; start;<br \/>\n\t\t\t\t\t_logTextView.append(FrostWireUtils.getBytesInHuman(length) + &quot; in &quot; + time + &quot; ms @ &quot; + (length\/(double) time)*1000 + &quot; b\/sn&quot;);<br \/>\n\t\t\t\t}<br \/>\n\t\t\t}<br \/>\n[\/java]<\/p>\n<p>And here&#8217;s how we do the MD5<br \/>\n[java]<br \/>\n\tpublic final static String getMD5(File f) throws Exception {<br \/>\n\t\tMessageDigest m = MessageDigest.getInstance(&quot;MD5&quot;);<\/p>\n<p>\t\tbyte[] buf = new byte[65536];<br \/>\n\t\tint num_read;<\/p>\n<p>\t\tInputStream in = new BufferedInputStream(new FileInputStream(f));<\/p>\n<p>\t\twhile ((num_read = in.read(buf)) != -1) {<br \/>\n\t\t\tm.update(buf, 0, num_read);<br \/>\n\t\t}<\/p>\n<p>\t\tString result = new BigInteger(1, m.digest()).toString(16);<\/p>\n<p>\t\t\/\/ pad with zeros if until it&#8217;s 32 chars long.<br \/>\n\t\tif (result.length() &lt; 32) {<br \/>\n\t\t\tStringBuffer padding = new StringBuffer();<br \/>\n\t\t\tint paddingSize = 32 &#8211; result.length();<br \/>\n\t\t\tfor (int i = 0; i &lt; paddingSize; i++)<br \/>\n\t\t\t\tpadding.append(&quot;0&quot;);<\/p>\n<p>\t\t\tresult = padding.toString() + result;<br \/>\n\t\t}<\/p>\n<p>\t\treturn result;<br \/>\n\t}<br \/>\n[\/java] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nexus 1 indeed. 17 files get their MD5 calculated on the Droid and 17 files get their MD5 hash calculated on the Nexus 1 Nexus 1 pwns. Here&#8217;s the code in case you&#8217;re curious. [java] public void onClick(View v) { _logTextView.setText(&quot;MD5 Benchmark on &quot; + Build.DEVICE + &quot;nn&quot;); if (GlobalVariables.APP_CONTEXT == null) GlobalVariables.APP_CONTEXT = getApplicationContext(); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5,15,30],"tags":[1434,188,1437],"class_list":["post-1928","post","type-post","status-publish","format-standard","hentry","category-android","category-code","category-geeklife","tag-android","tag-benchmark","tag-code"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-v6","jetpack-related-posts":[{"id":1526,"url":"https:\/\/www.gubatron.com\/blog\/droid-vs-nexus-1-sunspider-javascript-benchmark-showdown\/","url_meta":{"origin":1928,"position":0},"title":"Droid vs Nexus 1 &#8211; SunSpider JavaScript Benchmark showdown","author":"gubatron","date":"January 10, 2010","format":false,"excerpt":"Nexus One runs JavaScript 2.32 times faster than the Motorola Droid. The SunSpider JavaScript Benchmark was run several times on both phones and results were consistent. It'd be great to compare with the iPhone 3Gs, If someone has an iPhone 3Gs, please run the test and send me the results\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":747,"url":"https:\/\/www.gubatron.com\/blog\/safari-31-benchmark-part-ii-vs-firefox-30b4\/","url_meta":{"origin":1928,"position":1},"title":"Safari 3.1 Benchmark part II &#8211; VS Firefox 3.0b4","author":"gubatron","date":"March 20, 2008","format":false,"excerpt":"This is the Part II of Benchmarks between Safari 3.1's JavaScript engine and Firefox. Last Benchmark was done against Firefox 2, and Safari destroyed Firefox's Javascript engine, in some aspects being up to 7 times faster. So I was curious and I downloaded and tried the benchmark on Firefox 3.0b4.\u2026","rel":"","context":"In &quot;AJAX&quot;","block_context":{"text":"AJAX","link":"https:\/\/www.gubatron.com\/blog\/category\/ajax\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":744,"url":"https:\/\/www.gubatron.com\/blog\/new-safaris-javascript-engine-kicks-ass\/","url_meta":{"origin":1928,"position":2},"title":"New Safari&#8217;s JavaScript engine Kicks Ass!","author":"gubatron","date":"March 19, 2008","format":false,"excerpt":"So I downloaded yesterday the latest Software Update for Mac OSX and it included an update of the Safari Web Browser, which I had taken for dead ages ago, I'm a hardcore Firefox user. Today I read about the new updates, and I read something that caught my eye at\u2026","rel":"","context":"In &quot;AJAX&quot;","block_context":{"text":"AJAX","link":"https:\/\/www.gubatron.com\/blog\/category\/ajax\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1521,"url":"https:\/\/www.gubatron.com\/blog\/unboxing-nexus-one-spanish\/","url_meta":{"origin":1928,"position":3},"title":"Unboxing Nexus One (Spanish)","author":"gubatron","date":"January 9, 2010","format":false,"excerpt":"Unboxing and comparing the Nexus One to the Motorola Droid","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1961,"url":"https:\/\/www.gubatron.com\/blog\/nokia-n900-vs-nexus-one-vs-droid-hd-video-playback-comparison\/","url_meta":{"origin":1928,"position":4},"title":"Nokia N900 vs Nexus One vs Droid: HD Video Playback comparison","author":"gubatron","date":"May 23, 2010","format":false,"excerpt":"Grabbed the demo video that comes with the N900 to delight you and put it on the 3 phones. The screen on the Nexus One is the most impressive. The Droid has a 1\/2 sec. lag when you try to jump to another part of the video. If you don't\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1858,"url":"https:\/\/www.gubatron.com\/blog\/quick-motorola-cliq-review-att\/","url_meta":{"origin":1928,"position":5},"title":"Quick Motorola Cliq Review &#8211; AT&#038;T","author":"gubatron","date":"April 10, 2010","format":false,"excerpt":"Here is AT&T's\/Motorola Cliq downloading \"Bebbled\", a free game from the Android Marketplace. The one think I like about this phone is the keyboard, however It's very annoying that when it's closed the touchscreen side doesn't have the Search button that the Droid and the Nexus have. So, everytime you\u2026","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/1928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=1928"}],"version-history":[{"count":0,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/1928\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=1928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=1928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=1928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}