in reply to Making a base32 representation of md5
In other words, you have a 128 bit number, and you want to represent it in base32.
my $binary_digest = ...; my @digits = (0..9, 'A'..'V'); my $base32_digest = ''; for (0..3) { # 2^32^4 = 2^128 $base32_digest = $digits[$binary_digest & 31]. $base32_digest; $binary_digest >>= 5; } print("$base32_digest\n");
Update: Strike that. You don't start with a 128 bit number, it wouldn't fit. I'd reengineer my solution, but I must leave. Good luck.
|
|---|