Module: CryptoHelper
- Included in:
- Crypto
- Defined in:
- lib/crypto-lite/helper.rb
Instance Method Summary collapse
-
#base58(bin = ''.b, hex: nil) ⇒ Object
add convenience helpers.
- #base58check(bin = ''.b, hex: nil) ⇒ Object
- #hash160(bin = ''.b, hex: nil) ⇒ Object
- #hash256(bin = ''.b, hex: nil) ⇒ Object
- #keccak256(bin = ''.b, hex: nil) ⇒ Object
- #rmd160(bin = ''.b, hex: nil) ⇒ Object (also: #ripemd160)
- #sha256(bin = ''.b, hex: nil, engine: nil) ⇒ Object
- #sha3_256(bin = ''.b, hex: nil, engine: nil) ⇒ Object
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 |