Hype-2/static/utils/b64-to-binary.pl

18 lines
392 B
Perl
Raw Permalink Normal View History

2023-10-17 08:03:51 +00:00
#!/usr/bin/perl
use MIME::Base64;
for (<>) {
unless (/^'([{}])(\d+)\1(.+?)',$/) {
print;
next;
}
my ($dir, $amt, $b64) = ($1, $2, $3);
my $decoded = MIME::Base64::decode($b64) or die "Could not base64-decode line `$_`";
my $decoded_escaped = join "", map { "\\x$_" } unpack("(H2)*", $decoded);
print "'${dir}${amt}${dir}${decoded_escaped}',\n";
}