From: Brian Candler Date: 2008-10-24T05:30:21+09:00 Subject: Re: Big endian convention in Ruby Ashrith Barthur wrote: > I searched far and wide on the internet and I don't see anyone posting > this kind of an error .. I really dont get it as to why the code would > work with 64 loops but not 79 loops. The only answer I can give is trite: "because there is a bug in your program", or "because you are doing something wrong". If you don't post the code, then we cannot guess what you are doing wrong. At a guess: your input by this stage should consist of an array of 80 32-bit integers, and you should be indexing this array to obtain w[i]. Possibly you have set up this array wrongly. > Is it gotta do with the amount of numbers that are being inserted in > each value of the array? while unpacking I have defined it as H8*16 so > does that limit the size of each value in array? would it work if i say > N16? or is it a completely different error? Arrays in Ruby are of unlimited size (subject only to available RAM). FWIW, I have attached a direct translation of the pseudocode on Wikipedia. It seems to work for the handful of test vectors I've tried. $ echo -n "" | sha1sum da39a3ee5e6b4b0d3255bfef95601890afd80709 - $ echo -n "hello" | sha1sum aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d - $ echo -n "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | sha1sum 06ced2e070e58c2c4ed9f2b8cb890f0c512ce60d - Attachments: http://www.ruby-forum.com/attachment/2846/sha1.rb -- Posted via http://www.ruby-forum.com/.