From: aaaa aaaaaaaaaaa Date: 2010-08-18T07:05:49+09:00 Subject: Base64 multiple by 4 Hello, I'm in the need of a Base64 decoding method that can decode a string multiplied by 4. At the current moment I have the following method: def decode(encoded) if not encoded.length % 12 == 0 raise BadInputError, "can only decode strings which are a multiple of 4 characters." end decoded = String.new k = -1 while (k < encoded.length - 1) do right = 0 left = 0 (0..5).each do |i| k = k + 1 right |= encoding_characters.index(encoded[k]) << (i * 6) end (0..5).each do |i| k = k + 1 left |= encoding_characters.index(encoded[k]) << (i * 6) end (0..3).each do |i| decoded += ((left & (0xFF << ((3 - i) * 8))) >> ((3 - i) * 8)).chr end (0..3).each do |i| decoded += ((right & (0xFF << ((3 - i) * 8))) >> ((3 - i) * 8)).chr end end return decoded end What I need (to be exact) is a ruby port of the encode/decode method from http://www.koders.com/java/fid2B76F86B8F8FF984EFE3C04AC6DE198E40D8EF41.aspx Thanks in advance. -- Posted via http://www.ruby-forum.com/.