From: Brian Candler Date: 2012-04-29T18:54:14+09:00 Subject: Re: why does this return 255 bits instead of 256 (and general bit byte hex string array crypt mayhem Aaron D. Gifford wrote in post #1058735: > Example of #to_s "eating" leading zeros: Of course it does, because it can't guess how many leading zeros you want: >> 5.to_s(2) => "101" >> 7.to_s(2) => "111" >> 14.to_s(2) => "1110" >> 17.to_s(2) => "10001" If you want to tell it the number of digits, I suggest you use the %b format convertor. e.g. to force 32 bits: >> "%0.32b" % 17 => "00000000000000000000000000010001" However I question why you want to do this. You say you want to "get a binary representation of various components, and then I need to concatenate them and encrypt them together," By "binary representation" I'm pretty sure you don't really mean "ASCII '0' followed by ASCII '1' followed by ASCII '0' ..." The data you have *already* is binary, and you can just concatenate it and encrypt it. Converting it to text symbols is unlikely to achieve what you want. -- Posted via http://www.ruby-forum.com/.