#!/usr/bin/perl -n
#
# $Id$
#
# Script to convert plaintext MD5 hex signatures to bubble-babble
# fingerprints for easy human consumption. Accepts input on STDIN,
# prints bubble-babble format on STDOUT.
#
# Example usage: echo -n foo | openssl md5 | md52bb
# xorar-takyt-rufys-davuh-suruv-zinog-zifos-genet-moxix
use Digest::BubbleBabble qw( bubblebabble );
# look for md5 fingerprints, convert to raw form needed by
# Digest::BubbleBabble and feed to such
if (
m/
(
([a-f0-9]{2}:){15} # 15 leading hex "af:" groups
[a-f0-9]{2} # traing hex pair
)/ix
) {
my $md5_hex = $1;
$md5_hex =~ tr/://d;
print hex2bb($md5_hex), "\n";
} elsif (
m/
([a-f0-9]{32}) # guess raw md5_hex format with no :'s
/ix
) {
print hex2bb($1), "\n";
}
sub hex2bb {
bubblebabble(Digest => pack 'H*', shift);
}