summaryrefslogtreecommitdiff
path: root/utils/b64-to-binary.pl
blob: 280e28c93f03e75bf304718139165310c7ed408e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env 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";
}