Sha256: 772fc00a383a443a687cdef4e90d721f554c2878d64696316b9477168d0ae450

Contents?: true

Size: 569 Bytes

Versions: 9

Compression:

Stored size: 569 Bytes

Contents

require "base32"

module Fling
  # Encoder/decoder for z-base-32 used by Tahoe-LAFS
  module Encoding
    module_function

    # Encode a string in z-base-32
    #
    # @param string [String] arbitrary string to be encoded
    # @return [String] lovely, elegant z-base-32
    def encode(string)
      Base32.encode(string).downcase.sub(/=+$/, "")
    end

    # Decode a z-base-32 string
    #
    # @param string [String] z-base-32 string to be decoded
    # @return [String] decoded string
    def decode(string)
      Base32.decode(string.upcase)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fling-0.1.2 lib/fling/encoding.rb
fling-0.1.0 lib/fling/encoding.rb
fling-0.0.9 lib/fling/encoding.rb
fling-0.0.8 lib/fling/encoding.rb
fling-0.0.7 lib/fling/encoding.rb
fling-0.0.6 lib/fling/encoding.rb
fling-0.0.5 lib/fling/encoding.rb
fling-0.0.4 lib/fling/encoding.rb
fling-0.0.3 lib/fling/encoding.rb