shithub: riscv

ref: 5ebb1a29d8250027e8b7f2287f3bfa3a6f3d13ac
dir: /sys/src/ape/lib/openssl/demos/b64.pl/

View raw version
#!/usr/local/bin/perl

#
# Make PEM encoded data have lines of 64 bytes of data
#

while (<>)
	{
	if (/^-----BEGIN/ .. /^-----END/)
		{
		if (/^-----BEGIN/) { $first=$_; next; }
		if (/^-----END/) { $last=$_; next; }
		$out.=$_;
		}
	}
$out =~ s/\s//g;
$out =~ s/(.{64})/$1\n/g;
print "$first$out\n$last\n";