Thanks for digging into it. If I understand correctly, the AS code had a bug and should not have had the s[] code in it.
The JS problem is interesting. Some internet articles claim that JS does not have integers at all. So not sure what to make of the article you linked to. The code in the JS MD5 implementation is solving some other problem. It does not seem to try to sign extend the values, maybe because the values in an MD5 calculation are all unsigned. We may need to understand which modern browsers that we support (IE11, Chrome, FireFox, Android, IOS Safari) might have these issues. We might have to generate a "safeAdd()" instead of just "+" when we know the types are all integers. And implement smarter coercions as described in the article you linked to. Which browser(s) did you test with? -Alex On 6/22/18, 3:21 AM, "Harbs" <[email protected]> wrote: In Flash, the error is ReferenceError: Error: 1069. I took another look and it looks like the problem is the bracketed access to the BinaryData. The code s[ i / 8 ] needs to be changed to either s.readByteAt(i/8) or s.array[i/8]. Making either of these changes fixed the Flash error, but did not fix the JS error: expected 80338e79d2ca9b9c090ebaaa2ef293c7 but was: 996f93cb21f81b54962909fd0ea18074 I’m guessing that the problem is related to the comment here in the JS MD5 implementation: * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. I think part of the problem is that JS only has 32 bit ints. I did not follow this article completely, but this might shed some light: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.vjeux.com%2F2013%2Fjavascript%2Fconversion-from-uint8-to-int8-x-24.html&data=02%7C01%7Caharui%40adobe.com%7C21a1876d2a9b4e569ba008d5d829de4a%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636652596694550635&sdata=YyxMW%2BZfeuhZ1x8w%2BMxetw8FoZGhEqU0jIkZxyDc%2Bpg%3D&reserved=0 <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.vjeux.com%2F2013%2Fjavascript%2Fconversion-from-uint8-to-int8-x-24.html&data=02%7C01%7Caharui%40adobe.com%7C21a1876d2a9b4e569ba008d5d829de4a%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636652596694550635&sdata=YyxMW%2BZfeuhZ1x8w%2BMxetw8FoZGhEqU0jIkZxyDc%2Bpg%3D&reserved=0> Harbs > On Jun 22, 2018, at 9:22 AM, Alex Harui <[email protected]> wrote: > > On 6/21/18, 11:20 AM, "Harbs" <[email protected]> wrote: > > The MD5 test actually failed in Flash too. Although the error was different. > > I’m not sure why it was failing. I’m pretty sure the code was the same as the Flex version with ByteArray swapped for BinaryData. > > Even more bothersome. We really should dig deeper on this. We can't have other people's business logic have similar issues. Any volunteers? > > -Alex > >
