xref: /minix3/crypto/external/bsd/openssl/dist/demos/b64.pl (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc#!/usr/local/bin/perl
2*ebfedea0SLionel Sambuc
3*ebfedea0SLionel Sambuc#
4*ebfedea0SLionel Sambuc# Make PEM encoded data have lines of 64 bytes of data
5*ebfedea0SLionel Sambuc#
6*ebfedea0SLionel Sambuc
7*ebfedea0SLionel Sambucwhile (<>)
8*ebfedea0SLionel Sambuc	{
9*ebfedea0SLionel Sambuc	if (/^-----BEGIN/ .. /^-----END/)
10*ebfedea0SLionel Sambuc		{
11*ebfedea0SLionel Sambuc		if (/^-----BEGIN/) { $first=$_; next; }
12*ebfedea0SLionel Sambuc		if (/^-----END/) { $last=$_; next; }
13*ebfedea0SLionel Sambuc		$out.=$_;
14*ebfedea0SLionel Sambuc		}
15*ebfedea0SLionel Sambuc	}
16*ebfedea0SLionel Sambuc$out =~ s/\s//g;
17*ebfedea0SLionel Sambuc$out =~ s/(.{64})/$1\n/g;
18*ebfedea0SLionel Sambucprint "$first$out\n$last\n";
19*ebfedea0SLionel Sambuc
20*ebfedea0SLionel Sambuc
21