Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial import of Digest-BubbleBabble 0.01 from CPAN

git-cpan-module:   Digest-BubbleBabble
git-cpan-version:  0.01
git-cpan-authorid: BTROTT
git-cpan-file:     authors/id/B/BT/BTROTT/Digest-BubbleBabble-0.01.tar.gz
  • Loading branch information...
commit 0f00defc8148e7e45f8d2cad9ca2cd56d0ccaa06 0 parents
Benjamin Trott authored schwern committed
105 BubbleBabble.pm
@@ -0,0 +1,105 @@
+package Digest::BubbleBabble;
+use strict;
+
+use Exporter;
+use vars qw( @EXPORT_OK @ISA $VERSION );
+@ISA = qw( Exporter );
+@EXPORT_OK = qw( bubblebabble );
+
+$VERSION = '0.01';
+
+use vars qw( @VOWELS @CONSONANTS );
+@VOWELS = qw( a e i o u y );
+@CONSONANTS = qw( b c d f g h k l m n p r s t v z x );
+
+sub bubblebabble {
+ my %param = @_;
+ my @dgst = map ord, split //, $param{Digest};
+ my $dlen = length $param{Digest};
+
+ my $seed = 1;
+ my $rounds = ($dlen / 2) + 1;
+ my $retval = 'x';
+ for my $i (0..$rounds-1) {
+ if ($i+1 < $rounds || $dlen % 2) {
+ my $idx0 = ((($dgst[2 * $i] >> 6) & 3) + $seed) % 6;
+ my $idx1 = ($dgst[2 * $i] >> 2) & 15;
+ my $idx2 = (($dgst[2 * $i] & 3) + $seed / 6) % 6;
+ $retval .= $VOWELS[$idx0] . $CONSONANTS[$idx1] . $VOWELS[$idx2];
+ if ($i+1 < $rounds) {
+ my $idx3 = ($dgst[2 * $i + 1] >> 4) & 15;
+ my $idx4 = $dgst[2 * $i + 1] & 15;
+ $retval .= $CONSONANTS[$idx3] . '-' . $CONSONANTS[$idx4];
+ $seed = ($seed * 5 + $dgst[2 * $i] * 7 +
+ $dgst[2 * $i + 1]) % 36;
+ }
+ }
+ else {
+ my $idx0 = $seed % 6;
+ my $idx1 = 16;
+ my $idx2 = $seed / 6;
+ $retval .= $VOWELS[$idx0] . $CONSONANTS[$idx1] . $VOWELS[$idx2];
+ }
+ }
+ $retval .= 'x';
+ $retval;
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Digest::BubbleBabble - Create bubble-babble fingerprints
+
+=head1 SYNOPSIS
+
+ use Digest::BubbleBabble qw( bubblebabble );
+ use Digest::SHA1 qw( sha1 );
+
+ my $fingerprint = bubblebabble( Digest => sha1($message) );
+
+=head1 DESCRIPTION
+
+I<Digest::BubbleBabble> takes a message digest (generated by
+either of the MD5 or SHA-1 message digest algorithms) and creates
+a fingerprint of that digest in "bubble babble" format.
+Bubble babble is a method of representing a message digest
+as a string of "real" words, to make the fingerprint easier
+to remember. The "words" are not necessarily real words, but
+they look more like words than a string of hex characters.
+
+Bubble babble fingerprinting is used by the SSH2 suite
+(and, consequently, by I<Net::SSH::Perl>, the Perl SSH
+implementation) to display easy-to-remember key fingerprints.
+The key (a DSA or RSA key) is converted into a textual form,
+digested using I<Digest::SHA1>, and run through I<bubblebabble>
+to create the key fingerprint.
+
+=head1 USAGE
+
+I<Digest::BubbleBabble> conditionally exports one function called
+I<bubblebabble>; to import the function you must choose to
+import it, like this:
+
+ use Digest::BubbleBabble qw( bubblebabble );
+
+=head2 bubblebabble( Digest => $digest )
+
+Currently takes only one pair of arguments, the key of
+which must be I<Digest>, the value of which is the actual
+message digest I<$digest>. You should generate this message
+digest yourself using either I<Digest::MD5> of I<Digest::SHA1>.
+
+Returns the bubble babble form of the digest.
+
+=head1 AUTHOR & COPYRIGHTS
+
+Benjamin Trott, ben@rhumba.pair.com
+
+Except where otherwise noted, Digest::BubbleBabble is Copyright
+2001 Benjamin Trott. All rights reserved. Digest::BubbleBabble is
+free software; you may redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
6 Changes
@@ -0,0 +1,6 @@
+$Id: Changes,v 1.2 2001/05/03 01:15:20 btrott Exp $
+
+Revision history for Digest::BubbleBabble
+
+0.01 2001.05.02
+ - original version; created by h2xs 1.19
6 MANIFEST
@@ -0,0 +1,6 @@
+BubbleBabble.pm
+Changes
+MANIFEST
+Makefile.PL
+README
+test.pl
11 Makefile.PL
@@ -0,0 +1,11 @@
+# $Id: Makefile.PL,v 1.1.1.1 2001/05/03 01:11:11 btrott Exp $
+
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'Digest::BubbleBabble',
+ DISTNAME => 'Digest-BubbleBabble',
+ VERSION_FROM => 'BubbleBabble.pm',
+ AUTHOR => 'Benjamin Trott <ben@rhumba.pair.com>',
+ ABSTRACT => 'Create bubble-babble fingerprints',
+);
30 README
@@ -0,0 +1,30 @@
+$Id: README,v 1.2 2001/05/03 01:15:20 btrott Exp $
+
+This is Digest::BubbleBabble.
+
+PREREQUISITES
+
+None.
+
+INSTALLATION
+
+Digest::BubbleBabble installation is straightforward. If your
+cpan shell is set up, you should just be able to do
+
+ % perl -MCPAN -e 'install Digest::BubbleBabble'
+
+If you don't like that, you can download the distribution; the
+latest version on CPAN can be found in
+
+ ftp://ftp.cpan.org/pub/CPAN/authors/id/B/BT/BTROTT/
+
+Download it, unpack it, then build it as per the usual:
+
+ % perl Makefile.PL
+ % make && make test
+
+Then install it:
+
+ % make install
+
+Benjamin Trott / ben@rhumba.pair.com
19 test.pl
@@ -0,0 +1,19 @@
+# $Id: test.pl,v 1.4 2001/05/03 01:28:08 btrott Exp $
+
+use strict;
+
+use Test;
+BEGIN { plan tests => 3 }
+
+use vars qw( $loaded );
+END { print "not ok 1\n" unless $loaded; }
+use Digest::BubbleBabble qw( bubblebabble );
+$loaded++;
+ok($loaded);
+
+ok(defined &bubblebabble);
+
+my $dgst = pack "H*", "0a86c1b0428a6ce8103dfcc666519ae2918655d8";
+my $bb = "xedim-kibyr-bybum-poryv-migyf-tazes-kunah-cikev-dugom-kihat-maxyx";
+
+ok(bubblebabble( Digest => $dgst ), $bb);
Please sign in to comment.
Something went wrong with that request. Please try again.