From: Mike Bethany Date: 2012-04-28T02:20:41+09:00 Subject: Re: why does this return 255 bits instead of 256 (and general bit byte hex string array crypt mayhem --14dae93407cdd4dfbb04beac529e Content-Type: text/plain; charset=ISO-8859-1 I got 256 when running your code. It will always be 256 because of the hash you're using but I'm guessing you have some other use for this. I should also say that instead of those painful manipulations you could simply multiply the length of the hash by eight. The goal is to simplify, not complicate. #begin require 'openssl' hasher = OpenSSL::Digest::SHA256.new test_hash = hasher << "something" puts test_hash.length * 8 #end On Fri, Apr 27, 2012 at 12:21 PM, instance_variable ok wrote: > woot solved getting the binary string representation with this: > > puts OpenSSL::BN.new(test_hash_value.to_s, > 16).to_s(2).unpack("B*")[0].length > > => 256 > > -- > Posted via http://www.ruby-forum.com/. > > --14dae93407cdd4dfbb04beac529e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I got 256 when running your code. It will always be 256 because of the= hash you're using but I'm guessing you have some other use for thi= s.

I should also say that instead of those painful= manipulations you could simply multiply the length of the hash by eight.

The goal is to simplify, not=A0complicate.

=
#begin
require 'openssl'

hasher =3D OpenSSL::Digest::SHA256.new
test_hash =3D has= her << "something"

puts test_hash.length * 8

#end=


On Fri, Apr 27, 2012 at= 12:21 PM, instance_variable ok <lists@ruby-forum.com> wr= ote:
woot solved getting the binary string repres= entation with this:

puts OpenSSL::BN.new(test_hash_value.to_s,
16).to_s(2).unpack("B*")[0].length

=3D> 256

--
Posted via http://= www.ruby-forum.com/.


--14dae93407cdd4dfbb04beac529e--