Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10369] iOS: md5HexDigest hashing behaviour is inconsistent with other systems

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 2.1.1, Release 3.2.0
Fix Version/sn/a
ComponentsiOS
Labelscore, supportTeam
ReporterFederico Casali
AssigneeUnknown
Created2012-07-20T04:57:50.000+0000
Updated2018-02-28T20:04:24.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:55.000+00003
init5.js2012-07-20T04:57:50.000+00003

Comments

  1. James Turnbull 2012-11-21

    When I initially reported this issue I suggested an easy fix. Is there an expected version of the SDK that will include this easy fix?

JSON Source