]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_transform/misc/base32alpha2vals
Security-59754.41.1.tar.gz
[apple/security.git] / OSX / libsecurity_transform / misc / base32alpha2vals
1 #!/usr/bin/perl
2
3 # Quick & dirty, gennerate the Base32XVals for a given alphabet
4
5 use strict qw(vars);
6
7 if (1 != @ARGV) {
8 die "usage: $0 base32alphabet\n";
9 }
10 my $alphabet = $ARGV[0];
11 if (32 != length($alphabet)) {
12 die "alphabet needs exactly 32 charactors";
13 }
14
15 my @vals = (0xff) x 256;
16 $vals[ord('=')] = 0xee;
17
18 for(my $i = 0; $i < length($alphabet); $i++) {
19 my $ch = substr($alphabet, $i, 1);
20 my $v = ord($ch);
21 print "$i: $ch $v\n";
22
23 $vals[$v] = $i;
24 }
25
26 for(my $i = 0; $i < @vals; $i++) {
27 printf "0x%02x, ", $vals[$i];
28 print "\n" unless (($i-2) % 11);
29 }