我正在尝试将 SHA-2 256 位校验和存储在列中:
create_table :checksums do |t|
t.binary :value, :null => false, :limit => 32
end
我像这样存储值:
c = Checksum.new
big_num = Digest::SHA2.new.update("some string to be checksum'd").hexdigest.to_i(16)
c.value = big_num
在将 big_num 分配给 c.value 时,我得到:
NoMethodError: undefined method `gsub' for #<Bignum:0x00000001ea48f8>
有人知道我在做什么错吗?