Advertisement
paperline27

String to Hex.pl

Jan 21st, 2024
979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.53 KB | Source Code | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Term::ANSIColor;
  5. sub string_to_hex {
  6.     my $input_string = shift;
  7.     my $hex_representation = unpack("H*", $input_string);
  8.     return "0x$hex_representation";
  9. }
  10. print color('bold blue');
  11. print "Masukkan string yang ingin diubah ke heksadesimal: ";
  12. print color('reset');
  13. my $user_input = <STDIN>;
  14. chomp($user_input);
  15. my $hex_result = string_to_hex($user_input);
  16. print color('bold green');
  17. print "Representasi Heksadesimal dari '$user_input': $hex_result\n";
  18. print color('reset');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement