Base64:
http://perldoc.perl.org/MIME/Base64.html
文档中:The returned encoded string is broken into lines of no more than 76 characters each and it will end with $eol unless it is empty. Pass an empty string as second argument if you do not want the encoded string to be broken into lines.
我曾把java的证书文件xxx.cer转换成base64编码时,发现直接调用encode_base64( $bytes )函数产生的文件时76个字符每行,当把这种的证书转换成p7b格式时,发现是不能用的,因为可用证书为64个字符每行,于是使用encode_base64( $bytes, $eol )函数,$eol="",使得base64输出为一行,再分割为64个字符每行。
perl -MMIME::Base64 -e ' undef $/; # 使用默认的行模式 while(<>){ $str=encode_base64($_,""); } $str=reverse $str; #反转字符串 @arr = split("",$str); $count = length($str)/64; $ys=length($str)%64; $count++ if $ys!=0; for (1..$count) { for (1..64) { print pop(@arr); } print "\n"; } ' xxx.cer