I'm not a Flex programmer, but looking at the output, it would appear Flex is using integers that are something bigger than 32 bits (or more specifically, signed integers that are something bigger than 31 bits). Java is using 32-bit signed integers, hence the overflow to a large negative number (since the signed integer has a max value of 2^31).
The tip-off on Flex's use of >32-bit integers is the first argument - blk - is signed negative, but the result is signed positive, and is bigger than 2^31. To fix, you need to ensure Flex is storing the results of that calculation in only 32 bits. Then it would get the same results as the Java version. Since I'm not a Flex programmer, I honestly don't know for sure what you would need to change, though. HTH, Chris -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tiago Vale Sent: Wednesday, November 23, 2005 10:28 AM To: Flashcoders mailing list; Open Source Flash Mailing List Subject: [Flashcoders] Porting SHA-1 implementation from Java to AS3 Hi list, Im porting a SHA-1 implementation from java to AS3 and theres a strange behaviour that I cant deal with, I really dont know if this is a Java or a Flash question, but here it goes. JAVA tracing "int " + blk + " + " + 0x5A827999 + " + " + ro + " + " + prev+ " = " + data[z] output int -67371266 + 1518500249 + 585074272 + 271733878 = -1987030163 FLEX tracing "int " + blk + " + " + 0x5A827999 + " + " + ro + " + " + prev+ " = " + data[z] output int -67371266 + 1518500249 + 585074272 + 271733878 = 2307937133 I know some arithematics enough to know that a first glance Flex is dealing right, but since this implementation works with Java I reall whant to know whats wrongh here. this is happening in the R0 function. Thankz in advance Heres the Java source http://www.icksys.com/rqb/fdbc/SHA1.java Heres the AS3 source http://www.icksys.com/rqb/fdbc/SHA1.as -- Cheers Tiago Janz _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

