Replace OpenSSL base64 impl with a simple direct impl.
Unit tests, too.
This commit is contained in:
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use MIME::Base64;
|
||||
|
||||
my @vectors = (
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff",
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff",
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00",
|
||||
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
|
||||
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\x55\x55\x55\x55\x55\x55\x55\x55",
|
||||
"\x55\x55\x55\x55\x55\x55\x55\x55\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
|
||||
"\x01\x02\x04\x08\x10\x20\x40\x80\xfe\xfd\xfb\xf7\xef\xdf\xbf\x7f",
|
||||
);
|
||||
|
||||
print 'base64_test_row static_base64_vector[] = {' . "\n";
|
||||
for my $v (@vectors) {
|
||||
print ' { "';
|
||||
my @chars = split '', $v;
|
||||
for my $c (@chars) {
|
||||
printf "\\x%02x", ord($c);
|
||||
}
|
||||
print '", "' . encode_base64($v, "") . '" },' . "\n";
|
||||
}
|
||||
print ' { "", "" }' . "\n";
|
||||
print "};\n";
|
||||
Reference in New Issue
Block a user