From: Brian Candler Date: 2008-10-18T00:58:52+09:00 Subject: Re: Big endian convention in Ruby Just to make this clearer: the padding operation just pads the message up to a multiple of 64 bytes (512 bits), where the last block consists of 56 bytes (448 bits) followed by 8 bytes of message length. So assuming your message consists only of whole bytes, as your example implied, then I believe the padding operation is simply this: message = "A message" bits = message.size * 8 message << "\x80" message << "\x00" while (message.size & 63) != 56 message << [("%016X" % bits)].pack("H*") Now your message is exactly n * 64 bytes long, and you can proceed. -- Posted via http://www.ruby-forum.com/.