in reply to same encrypt word ?

Hi
Here is a working copy of code to encrypt / decrypt text based on Crypt::CBC using Rijndael Cipher. This is just to demonstrate that this is possible in perl.
Argument 1 to program is your key eg : 1234 and Argument 2 is a file to store the encrypted text
$perl crypt.pl 1234 crypt.txt
#! /Users/XXX/perl5/perlbrew/perls/perl-5.20.0/bin/perl use strict; use lib "/Users/XXX/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.2 +0.0/darwin-2level/Crypt/"; use Crypt::CBC; #use Crypt::Rijndael; my $cipher = Crypt::CBC->new( -key => $ARGV[0], -cipher => 'Rijndael' ); my $ciphertext = $cipher->encrypt("texttoencrypt"); open(my $fh,">",$ARGV[1]); print $fh $ciphertext; close $fh; my $plaintext = $cipher->decrypt($ciphertext); print "ciphertext " , $ciphertext,"\n"; print "plaintext " , $plaintext,"\n";

In order to get a better understanding of how the Crypt::CBC module works , the options and how to invoke the different methods look no further that metacpan.org where the module is documented.
If you are new to perl ,do skim through perldoc perlintro first, to understand basics about perl and pointers to the larger documentation set.

The temporal difficulty with perl is u need to know C well to know the awesome.else u just keep *using* it and writing inefficient code

Replies are listed 'Best First'.
Re^2: same encrypt word ?
by marto (Cardinal) on Oct 30, 2014 at 11:30 UTC
    #! /Users/XXX/perl5/perlbrew/perls/perl-5.20.0/bin/perl use strict; use lib "/Users/XXX/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.2 +0.0/darwin-2level/Crypt/";

    I'm curious as to why you are using perlbrew like this, and not simply switching to perl 5.20 via perlbrew switch perl-5.20.0


      i pulled this from a webserver i had uploaded the file too for my personal use.

      The temporal difficulty with perl is u need to know C well to know the awesome.else u just keep *using* it and writing inefficient code
Re^2: same encrypt word ?
by docofchaos (Novice) on Oct 30, 2014 at 11:32 UTC
    hi,
    i see this on the man page, but the result are
    U2FsdGVkX18c3I2mq/3SdvcofHkCyUhmdd0wS5dDtRw=
    i understand why this is not the same result with php function and the encrypt word is not the same if i reexecute the script.
    maybe i have a missing argument

      Hi, For an understanding, maybe this link https://metacpan.org/pod/MCryptwill help on the different constants u are using. But i think u need a basic understanding of cipher based encryption first and foremost. From my experience, Rijndael is the place to end your study,not start it, as it is one of the most current and IMHO complex ciphers around.. :D All the best! CBC (cipher block chaining) is especially suitable for encrypting files where the security is increased over ECB significantly.

      The temporal difficulty with perl is u need to know C well to know the awesome.else u just keep *using* it and writing inefficient code