Perl Mime模块

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 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值