Hi All,
I want to convert binary data to hexadecimal.
below is the code I used for the conversion.
It is converting only for 32 bit.
Can anybody suggest me for bit containing more tham 32(it may be 64 or 128).

Thanks and Regards
Nitesh



$str = "1010101010101010101010101010101010101010";
my $str2 = &bin2hex($str);
print "$str2\n\n";


sub bin2dec {
 return unpack("N", pack("B32", substr("0" x 32 . shift, -32)));
}

sub bin2hex {
   return sprintf("0x%x", bin2dec(shift));
}

Reply via email to