Rails: Storing a 256 bit checksum as binary in database
问题 I'm trying to store a SHA-2 256 bit checksum in a column: create_table :checksums do |t| t.binary :value, :null => false, :limit => 32 end I'm storing in the value like so: c = Checksum.new big_num = Digest::SHA2.new.update("some string to be checksum'd").hexdigest.to_i(16) c.value = big_num On the assignment of big_num to c.value I get: NoMethodError: undefined method `gsub' for #<Bignum:0x00000001ea48f8> Anybody know what I'm doing wrong? 回答1: If you're going to be storing your SHA2 in a