Skip to content

Instantly share code, notes, and snippets.

@yayitswei
Created September 12, 2013 06:09
Show Gist options
  • Save yayitswei/6533539 to your computer and use it in GitHub Desktop.
Save yayitswei/6533539 to your computer and use it in GitHub Desktop.
generate a seed (BigInt) from an arbitrary string
require 'digest'
class String
def to_seed
(Digest::SHA256.hexdigest(self).to_i(16))
end
end
puts "abc".to_seed => 84342368487090800366523834928142263660104883695016514377462985829716817089965
puts "123123123".to_seed => 66573445395556389320569794094825521729047035552620196053537129277119858926575
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment