base64.rb

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

Required files

kconv  

Methods

Public Instance methods

[Source]

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

[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

[Source]

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

[Source]

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

[Validate]