Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1906] md5 checksum for blobs on Android broken

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2013-03-20T16:03:42.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterJohan Lundin
AssigneeDaniel Sefton
Created2012-08-30T13:54:34.000+0000
Updated2016-03-08T07:40:49.000+0000

Description

The implementation of md5 checksum for Android is broken for binary blobs. In https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/utils/src/java/ti/modules/titanium/utils/UtilsModule.java the method public String md5HexDigest(Object obj) { String data = convertToString(obj); if (data != null) { return DigestUtils.md5Hex(data); } return null; } is incorrect since converting a blob to a string before computing md5 on it gives incorrect md5 checksums. The correct implementation should be public String md5HexDigest(Object obj) { if (obj instanceof String) { return DigestUtils.md5Hex((String)obj); } else if (obj instanceof TiBlob) { return DigestUtils.md5Hex(((TiBlob) obj).getBytes()); } return null; }

Comments

  1. Daniel Sefton 2013-03-20

    Fixed in master: https://github.com/appcelerator/titanium_mobile/commit/affe0d6fe188bf7aa58e0a08319a057ba36ad226#android/modules/utils/src/java/ti/modules/titanium/utils/UtilsModule.java

JSON Source