Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

Algoritimo da Cifra de Cesar em PERL

Collapse
X
 
  • Filter
  • Tempo
  • Show
Clear All
new posts

  • Font Size
    #1

    Perl Algoritimo da Cifra de Cesar em PERL

    Código:
    #!/usr/bin/perl -w
    #Coded by andreol263
    
    system("cls");
    print "Cesar Cipher Algorithm\n";
    
    print "Write something to be encrypted:\n";
    chomp(my $in = <STDIN>);
    %real_h = qw{
    	a c
    	b d
    	c e
    	d f
    	e g
    	f h
    	g i
    	h j
    	i k
    	j l
    	k m
    	l n
    	m o
    	n p
    	o q
    	p r
    	q s
    	r t
    	s u
    	t v
    	u w
    	v x
    	w y
    	x z
    	w a
    	z b
    };
    my (@has) = split(//, $in);
    my @hash = qw();
    my $num = @has;
    my $i;
    foreach $i (@has){
    	push @hash, $real_h{$i};
    }
    foreach(@hash){
    $string .= $_; 
    }
    print "the enc string is:$string";
    my @des;
    foreach $o(@hash){
    %desreal = reverse %real_h;	
    push @des, $desreal{$o}
    }
    foreach(@des){
    $desstring .= $_;
    }
    print "\n$desstring";

    Bem, este programinha cifra e decifra mensagens com o algoritmo de Cesar, bem simples, bom pra quem quer saber como fazer uma criptografia simples e para quem quer ver um programa pratico utilizando hashs
    sigpic


    Patati Patacula, la vem o pato para ver o que Ha!!
X
Working...
X