From: Reid Thompson Date: 2012-04-28T04:16:37+09:00 Subject: Re: why does this return 255 bits instead of 256 (and general bit byte hex string array crypt mayhem On Sat, 2012-04-28 at 03:10 +0900, instance_variable ok wrote: > Huh from IRB it shows 256 when I just went through it like you did, but > I know for sure earlier in my program it was saying 255 because it was > driving me crazy why it wasn't 256. I must have done it differently or > something. Anyway thanks! > > I have one more question and then will leave you all alone :P > > why is it if I do this > > hash = OpenSSL::Digest::SHA256.new > test_hash_value = hash << "anything" > puts test_hash_value.length > > it says 64 instead of 32 (*8 should = 256 but is equal to 512?) > > Is it because of something to do with hex? > what os are you on $ irb irb(main):001:0> require 'openssl' => true irb(main):002:0> require 'digest/sha2' => true irb(main):003:0> hash = OpenSSL::Digest::SHA256.new => # irb(main):004:0> test_hash_value = hash << "anything" => # irb(main):005:0> puts test_hash_value.length 32 => nil irb(main):006:0>