my $string = ...; # get the string from wherever $string = pack 'a256', $string; ## Will null pad to the specified length my $md5 = md5( $string ); ... do the twofish stuff.