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.22.0 lib/stellar/convert.rb
stellar-base-0.21.0 lib/stellar/convert.rb
stellar-base-0.20.0 lib/stellar/convert.rb
stellar-base-0.19.0 lib/stellar/convert.rb
stellar-base-0.18.0 lib/stellar/convert.rb
stellar-base-0.17.0 lib/stellar/convert.rb
stellar-base-0.16.0 lib/stellar/convert.rb
stellar-base-0.15.0 lib/stellar/convert.rb
stellar-base-0.14.0 lib/stellar/convert.rb
stellar-base-0.13.0 lib/stellar/convert.rb
stellar-base-0.12.0 lib/stellar/convert.rb
stellar-base-0.11.0 lib/stellar/convert.rb
auction-ruby-base-0.1.3 lib/stellar/convert.rb
auction-ruby-base-0.1.2 lib/stellar/convert.rb
auction-ruby-base-0.1.1 lib/stellar/convert.rb
stellar-base-0.10.0 lib/stellar/convert.rb
stellar-base-0.9.0 lib/stellar/convert.rb
stellar-base-0.8.0 lib/stellar/convert.rb
stellar-base-0.7.0 lib/stellar/convert.rb
stellar-base-0.6.1 lib/stellar/convert.rb