# base64.rb

Path: | base64.rb
Last Update: | Wed Jan 20 15:59:35 GMT+10:00 1999

## Required files

kconv

## Methods

b64encode decode64 decode_b encode64

## Public Instance methods

decode64(str)

[Source]

    # File base64.rb, line 3
    def decode64(str)
      str.unpack("m")[0]
    end

decode_b(str)

[Source]

    # File base64.rb, line 7
    def decode_b(str)
      str.gsub!(/=\?ISO-2022-JP\?B\?([!->@-~]+)\?=/i) {
        decode64($1)
      }
      str = Kconv::toeuc(str)
      str.gsub!(/=\?SHIFT_JIS\?B\?([!->@-~]+)\?=/i) {
        decode64($1)
      }
      str = Kconv::toeuc(str)
      str.gsub!(/\n/, ' ')
      str.gsub!(/\0/, '')
      str
    end

encode64(bin)

[Source]

    # File base64.rb, line 21
    def encode64(bin)
      [bin].pack("m")
    end

b64encode(bin, len = 60)

[Source]

    # File base64.rb, line 25
    def b64encode(bin, len = 60)
      encode64(bin).scan(/.{1,#{len}}/o) do
        print $&, "\n"
      end
    end

[Validate]