Module: Cryptos::Utils::Hexas
Instance Method Summary
collapse
Methods included from Bytes
#bignum_to_bytes, #bytes_to_bignum
Instance Method Details
#bignum_to_hex(value, size = 32) ⇒ Object
26
27
28
|
# File 'lib/cryptos/utils/hexas.rb', line 26
def bignum_to_hex(value, size = 32)
bin_to_hex bignum_to_bytes(value, size)
end
|
#bin_to_hex(binary_bytes) ⇒ Object
6
7
8
|
# File 'lib/cryptos/utils/hexas.rb', line 6
def bin_to_hex(binary_bytes)
binary_bytes.unpack('H*').first
end
|
#byte_to_hex(value) ⇒ Object
10
11
12
|
# File 'lib/cryptos/utils/hexas.rb', line 10
def byte_to_hex(value)
bin_to_hex [value].pack('C')
end
|
#bytes_to_hex(value) ⇒ Object
14
15
16
|
# File 'lib/cryptos/utils/hexas.rb', line 14
def bytes_to_hex(value)
bin_to_hex value.pack('C*')
end
|
#hex_size(hex) ⇒ Object
34
35
36
|
# File 'lib/cryptos/utils/hexas.rb', line 34
def hex_size(hex)
[hex].pack('H*').size
end
|
#hex_to_little(value) ⇒ Object
30
31
32
|
# File 'lib/cryptos/utils/hexas.rb', line 30
def hex_to_little(value)
bin_to_hex [value].pack('H*').reverse
end
|
#int_to_hex(value) ⇒ Object
18
19
20
|
# File 'lib/cryptos/utils/hexas.rb', line 18
def int_to_hex(value)
bin_to_hex [value].pack('V')
end
|
#long_to_hex(value) ⇒ Object
22
23
24
|
# File 'lib/cryptos/utils/hexas.rb', line 22
def long_to_hex(value)
bin_to_hex [value].pack('Q<')
end
|