Sha256: 3ccb07e8d69ea71b3f9d635fb9d339dc8f793b1a157eb9767026744c847c40aa

Contents?: true

Size: 377 Bytes

Versions: 1

Compression:

Stored size: 377 Bytes

Contents

# frozen_string_literal: true

module TJSON
  # Binary serialization helpers
  module Binary
    module_function

    def base16(string)
      "b16:#{string.unpack('H*').first}"
    end

    def base32(string)
      "b32:#{Base32.encode(string).downcase.delete('=')}"
    end

    def base64(string)
      "b64:#{Base64.urlsafe_encode64(string).delete('=')}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tjson-0.1.0 lib/tjson/binary.rb