Sha256: 688ef046bbcf15a02a61cad069361dbba7d0098d4542c583601881c35767500a

Contents?: true

Size: 635 Bytes

Versions: 29

Compression:

Stored size: 635 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

    ## Converts a Stellar::PublicKey instance (or any typedef of it such as
    # Stellar::AccountID) to an address
    def pk_to_address(pk)
      Stellar::Util::StrKey.check_encode(:account_id, pk.ed25519!)
    end

    extend self
  end
end

Version data entries

29 entries across 29 versions & 3 rubygems

Version Path
stellar-base-0.6.0 lib/stellar/convert.rb
stellar-base-0.5.0 lib/stellar/convert.rb
stellar-base-0.4.0 lib/stellar/convert.rb
open-core-0.3.0 lib/stellar/convert.rb
stellar-base-0.3.0 lib/stellar/convert.rb
stellar-base-0.2.0 lib/stellar/convert.rb
stellar-base-0.1.4 lib/stellar/convert.rb
stellar-base-0.1.3 lib/stellar/convert.rb
stellar-base-0.1.2 lib/stellar/convert.rb