Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10370] Android: md5HexDigest hashing behaviour is inconsistent with other systems

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-05-26T13:36:44.000+0000
Affected Version/sRelease 2.1.1, Release 3.1.0, Release 3.2.0
Fix Version/sn/a
ComponentsAndroid
Labelscore, exalture
ReporterFederico Casali
AssigneeSunila
Created2012-08-09T09:23:22.000+0000
Updated2017-03-27T18:33:30.000+0000

Description

Problem description

Creating an md5sum of a text-like file that does not conform exactly to UTF-8 produces a different hash from mac or linux systems, reducing its use as file validation.

Steps to reproduce

Mac and Ubuntu systems both give the following MD5 sum for the attached file: MD5 (init5.js) = 693e9af84d3dfcc71e640e005bdc5e2e using the following titanium code:
var win = Ti.UI.createWindow({
	backgroundColor:'white'
});

win.addEventListener('click', function() {
	var file = Titanium.Filesystem.getFile("init5.js");
	var blob = file.read();
	var md5sum = Titanium.Utils.md5HexDigest(blob);
	Ti.API.info("md5 is  " + md5sum);
	alert(md5sum);
});

win.open();
produces a different MD5 output (on both Android and iOS) = d41d8cd98f00b204e9800998ecf8427e , different from the one generated from Mac OS X or Ubuntu Linux

Attachments

FileDateSize
init5.js2012-08-09T09:24:34.000+00003
iOS Simulator Screen shot Mar 21, 2013 2.34.40 PM.png2013-03-21T09:35:35.000+000041211
Screenshot_2013-03-21-14-38-28.png2013-03-21T09:39:25.000+000028887

Comments

  1. Shameer Jan 2013-03-21

    Android MD5 sum : d41d8cd98f00b204e9800998ecf8427e, but it shows error on iphone emulator(see screen shot). Attached code(init5.js) is empty
  2. Sunila 2013-05-26

    Tried with 3.2.0, cannot reproduce.
  3. Lee Morris 2017-03-27

    Closing ticket as I am unable to reproduce this issue with the following environment; Pixel (7.1) MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.0.3 GA Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80

JSON Source