rubyは改行はずしても戻る。
hdknr@deb09:~/openidtx/openidtx/samples/cx$ irb irb(main):001:0> require 'base64' => true irb(main):002:0> Base64.encode64(open('openid.py').read).split.length => 166 irb(main):003:0> Base64.decode64(Base64.encode64(open('/etc/resolv.conf').read)) => "nameserver 127.0.0.1\nnameserver 192.168.250.2\n" irb(main):004:0> Base64.decode64(Base64.encode64(open('/etc/resolv.conf').read).gsub("\n","")) => "nameserver 127.0.0.1\nnameserver 192.168.250.2\n" irb(main):009:0> Base64.decode64(Base64.encode64(open('openid.py').read).gsub("\n",""))
phpも問題ない。
hdknr@deb09:~/openidtx/openidtx/samples/cx$ more test.php
<?php
echo base64_decode(file_get_contents(‘hoge.txt’));
hdknr@deb09:~/openidtx/openidtx/samples/cx$ more hoge.rb
require ‘base64’
puts Base64.encode64( open(‘openid.py’).read )
hdknr@deb09:~/openidtx/openidtx/samples/cx$ ruby hoge.rb > hoge.txt
hdknr@deb09:~/openidtx/openidtx/samples/cx$ wc hoge.txt
166 166 10094 hoge.txt
hdknr@deb09:~/openidtx/openidtx/samples/cx$ php test.php
でもとにもどる。
pythonも戻る
hdknr@deb09:~/openidtx/openidtx/samples/cx$ irb irb(main):001:0> b64encode(open('openid.py').read).split.length hdknr@deb09:~/openidtx/openidtx/samples/cx$ python Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import base64 >>> base64.b64encode( ''.join(open('/etc/resolv.conf').readlines())) 'bmFtZXNlcnZlciAxMjcuMC4wLjEKbmFtZXNlcnZlciAxOTIuMTY4LjI1MC4yCg==' >>> base64.b64decode(base64.b64encode( ''.join(open('/etc/resolv.conf').readlines()))) 'nameserver 127.0.0.1\nnameserver 192.168.250.2\n' >>> base64.b64decode(base64.encodestring( ''.join(open('/etc/resolv.conf').readlines()))) 'nameserver 127.0.0.1\nnameserver 192.168.250.2\n'
また、
hdknr@deb09:~/openidtx/openidtx/samples/cx$ python Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import base64 >>> base64.b64decode(''.join(open('hoge.txt').readlines()))
でもどりました。
広告