Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: BigBear en 13 Diciembre 2014, 15:23 pm



Título: [Perl] Ejemplo de Cifrado Vigenere
Publicado por: BigBear en 13 Diciembre 2014, 15:23 pm
Un simple ejemplo del cifrado Vigenere que hice usando un modulo que encontre en cpan.

El codigo :

Código
  1. # !usr/bin/perl
  2. # Vigenere Cipher
  3. # Coded By Doddy Hackman in the year 2014
  4.  
  5. use Crypt::Vigenere;
  6.  
  7. head();
  8. menu();
  9. copyright();
  10.  
  11. # Functions
  12.  
  13. sub head {
  14.    print "\n-- == Vigenere Cipher == --\n";
  15. }
  16.  
  17. sub copyright {
  18.    print "\n\n-- == (C) Doddy Hackman 2014 == --\n";
  19. }
  20.  
  21. sub menu {
  22.    print qq(
  23. ===============
  24. = Menu        =
  25. ===============
  26. 1 - Encode    =
  27. 2 - Decode    =
  28. 3 - Exit      =
  29. ===============
  30. );
  31.  
  32.    print "\n[+] Option : ";
  33.    chomp( my $op = <stdin> );
  34.  
  35.    if ( $op eq "3" ) {
  36.        copyright();
  37.        <stdin>;
  38.        exit(1);
  39.    }
  40.  
  41.    print "\n[+] Enter text : ";
  42.    chomp( my $text = <stdin> );
  43.  
  44.    print "\n[+] Enter Key : ";
  45.    chomp( my $key = <stdin> );
  46.  
  47.    print "\n[+] Result ...\n\n";
  48.  
  49.    $tool = Crypt::Vigenere->new($key);
  50.  
  51.    if ( $op eq "1" ) {
  52.        print $tool->encodeMessage($text);
  53.        <stdin>;
  54.        menu();
  55.    }
  56.    elsif ( $op eq "2" ) {
  57.        print $tool->decodeMessage($text);
  58.        <stdin>;
  59.        menu();
  60.    }
  61.    else {
  62.        menu();
  63.    }
  64.  
  65. }
  66.  
  67. # The End ?
  68.  

Eso es todo.