1Simple(3) User Contributed Perl Documentation Simple(3)
2
3
4
6 Crypt::Simple - encrypt stuff simply
7
9 use Crypt::Simple;
10
11 my $data = encrypt(@stuff);
12
13 my @same_stuff = decrypt($data);
14
16 Maybe you have a web application and you need to store some session
17 data at the client side (in a cookie or hidden form fields) but you
18 don't want the user to be able to mess with the data. Maybe you want
19 to save secret information to a text file. Maybe you have better ideas
20 of what to do with encrypted stuff!
21
22 This little module will convert all your data into nice base64 text
23 that you can save in a text file, send in an email, store in a cookie
24 or web page, or bounce around the Net. The data you encrypt can be as
25 simple or as complicated as you like.
26
28 If you don't pass any options when using "Crypt::Simple" we will
29 generate a key for you based on the name of your module that uses this
30 one. In many cases this works fine, but you may want more control over
31 the key. Here's how:
32
33 use Crypt::Simple passphrase => 'pass phrase';
34 The MD5 hash of the text string "pass phrase" is used as the key.
35
36 use Crypt::Simple prompt => 'Please type the magic words';
37 The user is prompted to enter a passphrase, and the MD5 hash of the
38 entered text is used as the key.
39
40 use Crypt::Simple passfile => '/home/marty/secret';
41 The contents of the file /home/marty/secret are used as the pass
42 phrase: the MD5 hash of the file is used as the key.
43
44 use Crypt::Simple file => '/home/marty/noise';
45 The contents of the file /home/marty/noise are directly used as the
46 key.
47
49 "Crypt::Simple" is really just a wrapper round a few other useful Perl
50 modules: you may want to read the documentation for these modules too.
51
52 We use "FreezeThaw" to squish all your data into a concise textual
53 representation. We use "Compress::Zlib" to compress this string, and
54 then use "Crypt::Blowfish" in a home-brew CBC mode to perform the
55 encryption. Somewhere in this process we also add a MD5 digest (using
56 "Digest::MD5"). Then we throw the whole thing through "MIME::Base64"
57 to produce a nice bit of text for you to play with.
58
59 Decryption, obviously, is the reverse of this process.
60
62 Governments throughout the world do not like encryption because it
63 makes it difficult for them to look at all your stuff. Each country
64 has a different policy designed to stop you using encryption: some
65 governments are honest enough to make it illegal; some think it is a
66 dangerous weapon; some insist that you are free to encrypt, but only
67 evil people would want to; some make confusing and contradictory laws
68 because they try to do all of the above.
69
70 Although this modules itself does not include any encryption code, it
71 does use another module that contains encryption code, and this
72 documentation mentions encryption. Downloading, using, or reading this
73 modules could be illegal where you live.
74
76 Marty Pauley <marty@kasei.com>
77
79 Copyright (C) 2001 Kasei Limited
80
81 This program is free software; you can redistribute it and/or modify it under
82 the terms of the GNU General Public License; either version 2 of the License,
83 or (at your option) any later version.
84
85 This program is distributed in the hope that it will be useful, but WITHOUT
86 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
87 FOR A PARTICULAR PURPOSE.
88
89
90
91perl v5.36.0 2023-01-20 Simple(3)