Module: BTC::StringExtensions
- Included in:
- String
- Defined in:
- lib/btcruby/extensions.rb
Instance Method Summary collapse
- 
  
    
      #from_hex  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Converts hex string into a binary data. 
- 
  
    
      #from_wif  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Decodes string in WIF format into a binary private key (32 bytes). 
- #hash160 ⇒ Object
- 
  
    
      #hash256  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Various hash functions. 
- #ripemd160 ⇒ Object
- #sha1 ⇒ Object
- #sha256 ⇒ Object
- #sha512 ⇒ Object
- 
  
    
      #to_hex  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Converts binary data into hex string. 
- 
  
    
      #to_wif(network: nil, public_key_compressed: nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Converts binary string as a private key to a WIF Base58 format. 
Instance Method Details
#from_hex ⇒ Object
Converts hex string into a binary data
| 21 22 23 | # File 'lib/btcruby/extensions.rb', line 21 def from_hex BTC.from_hex(self) end | 
#from_wif ⇒ Object
Decodes string in WIF format into a binary private key (32 bytes)
| 10 11 12 13 | # File 'lib/btcruby/extensions.rb', line 10 def from_wif addr = BTC::WIF.new(string: self) addr ? addr.private_key : nil end | 
#hash160 ⇒ Object
| 30 31 32 | # File 'lib/btcruby/extensions.rb', line 30 def hash160 BTC.hash160(self) end | 
#hash256 ⇒ Object
Various hash functions
| 26 27 28 | # File 'lib/btcruby/extensions.rb', line 26 def hash256 BTC.hash256(self) end | 
#ripemd160 ⇒ Object
| 38 39 40 | # File 'lib/btcruby/extensions.rb', line 38 def ripemd160 BTC.ripemd160(self) end | 
#sha256 ⇒ Object
| 42 43 44 | # File 'lib/btcruby/extensions.rb', line 42 def sha256 BTC.sha256(self) end | 
#sha512 ⇒ Object
| 46 47 48 | # File 'lib/btcruby/extensions.rb', line 46 def sha512 BTC.sha512(self) end | 
#to_hex ⇒ Object
Converts binary data into hex string
| 16 17 18 | # File 'lib/btcruby/extensions.rb', line 16 def to_hex BTC.to_hex(self) end | 
#to_wif(network: nil, public_key_compressed: nil) ⇒ Object
Converts binary string as a private key to a WIF Base58 format.
| 5 6 7 | # File 'lib/btcruby/extensions.rb', line 5 def to_wif(network: nil, public_key_compressed: nil) BTC::WIF.new(private_key: self, network: network, public_key_compressed: public_key_compressed).to_s end |