Class: Faker::Bitcoin

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/bitcoin.rb

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

.addressObject



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