Sha256: 1718894ef8f09574618580f70ce274099492416d09738713d51703274ff1c8ff

Contents?: true

Size: 510 Bytes

Versions: 2

Compression:

Stored size: 510 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 pk_to_address(pk)
      Stellar::util::StrKey.check_encode(:account_id, pk)
    end

    extend self
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stellar-base-0.1.1 lib/stellar/convert.rb
stellar-base-0.1.0 lib/stellar/convert.rb