Sha256: dd92f93aee4424f62e86834bb2c38c3a3599cf755a34725bdda494a1892bfec9

Contents?: true

Size: 555 Bytes

Versions: 10

Compression:

Stored size: 555 Bytes

Contents

module Stellar
  #
  # Generic format conversion module
  #
  module Convert
    require 'base64'

    def to_hex(string)
      string.unpack("H*").first
    end

    def from_hex(hex_string)
      [hex_string].pack("H*")
    end

    def to_base64(string)
      Base64.strict_encode64(string)
    end

    def from_base64(base64_string)
      Base64.strict_decode64(base64_string)
    end

    def base58
      Stellar::Util::Base58.stellar
    end

    def pk_to_address(pk)
      base58.check_encode(:account_id, pk)
    end

    extend self
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
stellar-base-0.0.20 lib/stellar/convert.rb
stellar-base-0.0.19 lib/stellar/convert.rb
stellar-base-0.0.18 lib/stellar/convert.rb
stellar-base-0.0.17 lib/stellar/convert.rb
stellar-base-0.0.16 lib/stellar/convert.rb
stellar-base-0.0.15 lib/stellar/convert.rb
stellar-base-0.0.14 lib/stellar/convert.rb
stellar-base-0.0.13 lib/stellar/convert.rb
stellar-base-0.0.12 lib/stellar/convert.rb
stellar-base-0.0.11 lib/stellar/convert.rb