Module: CryptoHelper

Included in:
Crypto
Defined in:
lib/crypto-lite/helper.rb

Instance Method Summary collapse

Instance Method Details

#base58(bin = ''.b, hex: nil) ⇒ Object

add convenience helpers



10
11
12
13
# File 'lib/crypto-lite/helper.rb', line 10

def base58( bin=''.b, hex: nil )
  bin = hex.hex_to_bin  if hex      # uses Bytes.hex_to_bin
  Crypto::Metal.base58( bin )
end

#base58check(bin = ''.b, hex: nil) ⇒ Object



15
16
17
18
# File 'lib/crypto-lite/helper.rb', line 15

def base58check( bin=''.b, hex: nil )
  bin = hex.hex_to_bin  if hex      # uses Bytes.hex_to_bin
  Crypto::Metal.base58check( bin )
end

#hash160(bin = ''.b, hex: nil) ⇒ Object



44
45
46
47
# File 'lib/crypto-lite/helper.rb', line 44

def hash160( bin=''.b, hex: nil )
  bin = hex.hex_to_bin  if hex      # uses Bytes.hex_to_bin
  Crypto::Metal.hash160( bin )
end

#hash256(bin = ''.b, hex: nil) ⇒ Object



49
50
51
52
# File 'lib/crypto-lite/helper.rb', line 49

def hash256( bin=''.b, hex: nil )
  bin = hex.hex_to_bin  if hex      # uses Bytes.hex_to_bin
  Crypto::Metal.hash256( bin )
end

#keccak256(bin = ''.b, hex: nil) ⇒ Object



20
21
22
23
# File 'lib/crypto-lite/helper.rb', line 20

def keccak256( bin=''.b, hex: nil )
   bin = hex.hex_to_bin  if hex      # uses Bytes.hex_to_bin
   Crypto::Metal.keccak256( bin )
end

#rmd160(bin = ''.b, hex: nil) ⇒ Object Also known as: ripemd160



25
26
27
28
# File 'lib/crypto-lite/helper.rb', line 25

def rmd160( bin=''.b, hex: nil )
  bin = hex.hex_to_bin  if hex      # uses Bytes.hex_to_bin
  Crypto::Metal.rmd160( bin )
end

#sha256(bin = ''.b, hex: nil, engine: nil) ⇒ Object



32
33
34
35
36
# File 'lib/crypto-lite/helper.rb', line 32

def sha256( bin=''.b, hex: nil,
                 engine: nil )
  bin = hex.hex_to_bin  if hex      # uses Bytes.hex_to_bin
  Crypto::Metal.sha256( bin, engine )
end

#sha3_256(bin = ''.b, hex: nil, engine: nil) ⇒ Object



38
39
40
41
42
# File 'lib/crypto-lite/helper.rb', line 38

def sha3_256( bin=''.b, hex: nil,
                   engine: nil )
  bin = hex.hex_to_bin  if hex      # uses Bytes.hex_to_bin
  Crypto::Metal.sha3_256( bin, engine )
end