Skip to content

Instantly share code, notes, and snippets.

@coderxin
Forked from andrewbroman/checksum.rb
Created December 6, 2022 14:30
Show Gist options
  • Save coderxin/59a986a900532fd07e0cc93be0f4880e to your computer and use it in GitHub Desktop.
Save coderxin/59a986a900532fd07e0cc93be0f4880e to your computer and use it in GitHub Desktop.
Ruby: create checksum on hash
# Thanks to tenderlove on Peepcode play by play
require 'digest/md5'
def fetch username
records = JSON.parse get username
records.each do |hash|
checksum = Digest::MD5.hexdigest Marshal.dump(hash)
hash['checksum'] = checksum
end
records
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment