I have a 128-bit Bignum that I need to pack into a binary string in
order to pass it to MD5.digest(). But there doesn’t appear to be a
format for Array#pack that would accommodate such a large number; the
biggest appears to be “L”, which is only a quarter the size I need.
I have a 128-bit Bignum that I need to pack into a binary string in
order to pass it to MD5.digest(). But there doesn’t appear to be a
format for Array#pack that would accommodate such a large number; the
biggest appears to be “L”, which is only a quarter the size I need.
What’s the best way to do this?
Perhaps not as efficient as you expect:
a)
b = 128-bit bignum value
data =
4.times{|i|
data.unshift (b>>i*32)&0xffffffff
}
data.pack(“NNNN”)