class HexFormatter::DigixGold
Public Instance Methods
decode(data)
click to toggle source
# File lib/hex_formatter.rb, line 37 def decode(data) payload = data.gsub("Dg", "") return "0x#{::Eth::Utils.bin_to_hex(::Base58.base58_to_binary(payload, :bitcoin))[2..-1]}" end
encode(data)
click to toggle source
# File lib/hex_formatter.rb, line 26 def encode(data) payload = data.gsub("0x", "").scan(/../).map(&:hex) raise ArgumentError if payload.length != 32 if payload[0] > 60 new_payload = "01" + data.gsub("0x", "") else new_payload = "02" + data.gsub("0x", "") end return "Dg#{::Base58.int_to_base58(new_payload.hex, :bitcoin)}" end