logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Crypt::Simple - encrypt stuff simply

Author

       Marty Pauley <marty@kasei.com>

Description

       Maybe you have a web application and you need to store some session data at the client side (in a cookie
       or hidden form fields) but you don't want the user to be able to mess with the data.  Maybe you want to
       save secret information to a text file.  Maybe you have better ideas of what to do with encrypted stuff!

       This little module will convert all your data into nice base64 text that you can save in a text file,
       send in an email, store in a cookie or web page, or bounce around the Net.  The data you encrypt can be
       as simple or as complicated as you like.

Internals

       "Crypt::Simple" is really just a wrapper round a few other useful Perl modules: you may want to read  the
       documentation for these modules too.

       We   use  "FreezeThaw"  to  squish  all  your  data  into  a  concise  textual  representation.   We  use
       "Compress::Zlib" to compress this string, and then use "Crypt::Blowfish"  in  a  home-brew  CBC  mode  to
       perform  the encryption.  Somewhere in this process we also add a MD5 digest (using "Digest::MD5").  Then
       we throw the whole thing through "MIME::Base64" to produce a nice bit of text for you to play with.

       Decryption, obviously, is the reverse of this process.

Key

       If you don't pass any options when using "Crypt::Simple" we will generate a key for you based on the name
       of your module that uses this one.  In many cases this works fine, but you may want more control over the
       key.  Here's how:

       use Crypt::Simple passphrase => 'pass phrase';
           The MD5 hash of the text string "pass phrase" is used as the key.

       use Crypt::Simple prompt => 'Please type the magic words';
           The user is prompted to enter a passphrase, and the MD5 hash of the entered text is used as the key.

       use Crypt::Simple passfile => '/home/marty/secret';
           The  contents of the file /home/marty/secret are used as the pass phrase: the MD5 hash of the file is
           used as the key.

       use Crypt::Simple file => '/home/marty/noise';
           The contents of the file /home/marty/noise are directly used as the key.

Name

       Crypt::Simple - encrypt stuff simply

Synopsis

         use Crypt::Simple;

         my $data = encrypt(@stuff);

         my @same_stuff = decrypt($data);

Warning

       Governments throughout the world do not like encryption because it makes it difficult for them to look at
       all your stuff.  Each country has a  different  policy  designed  to  stop  you  using  encryption:  some
       governments  are  honest enough to make it illegal; some think it is a dangerous weapon; some insist that
       you are free to encrypt, but only evil people would want to; some make confusing and  contradictory  laws
       because they try to do all of the above.

       Although  this  modules  itself  does  not  include  any encryption code, it does use another module that
       contains encryption code, and this documentation mentions encryption.   Downloading,  using,  or  reading
       this modules could be illegal where you live.

See Also