Class: Faker::Bitcoin
Constant Summary
Constants inherited from Base
Faker::Base::Letters, Faker::Base::Numbers, Faker::Base::ULetters
Class Method Summary collapse
Methods inherited from Base
bothify, fetch, flexible, letterify, method_missing, numerify, parse, regexify, translate
Class Method Details
.address ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/faker/bitcoin.rb', line 7 def address hash = rand(2**160).to_s(16) version = 0 packed = version.chr + [hash].pack("H*") checksum = Digest::SHA2.digest(Digest::SHA2.digest(packed))[0..3] base58(packed + checksum) end |