1Crypt::CipherSaber(3) User Contributed Perl DocumentationCrypt::CipherSaber(3)
2
3
4

NAME

6       Crypt::CipherSaber - Perl module implementing CipherSaber encryption.
7

SYNOPSIS

9         use Crypt::CipherSaber;
10         my $cs = Crypt::CipherSaber->new('my pathetic secret key');
11
12         my $coded = $cs->encrypt('Here is a secret message for you');
13         my $decoded = $cs->decrypt($coded);
14
15         # encrypt from and to a file
16         open(INFILE, 'secretletter.txt') or die "Can't open infile: $!";
17         open(OUTFILE, '>secretletter.cs1') or die "Can't open outfile: $!";
18         binmode(INFILE);
19         binmode(OUTFILE);
20         $cs->fh_crypt(\*INFILE, \*OUTFILE, 1);
21
22         # decrypt from and to a file
23         open(INFILE, 'secretletter.cs1') or die "Can't open infile: $!";
24         open(OUTFILE, '>secretletter.txt') or die "Can't open outfile: $!";
25         binmode(INFILE);
26         binmode(OUTFILE);
27         $cs->fh_crypt(\*INFILE, \*OUTFILE);
28

DESCRIPTION

30       The Crypt::CipherSaber module implements CipherSaber encryption,
31       described at <http://ciphersaber.gurus.com/>.  It is simple, fairly
32       speedy, and relatively secure algorithm based on RC4.
33
34       Encryption and decryption are done based on a secret key, which must be
35       shared with all intended recipients of a message.
36

METHODS

38       new($key, $N)
39           Initialize a new Crypt::CipherSaber object.  $key is a required
40           parameter: the key used to encrypt or to decrypt messages.  $N is
41           optional.  If provided and greater than one, it causes the object
42           to use CipherSaber-2 encryption (slightly slower but more secure).
43           If not specified, or equal to 1, the module defaults to
44           CipherSaber-1 encryption.  $N must be a positive integer greater
45           than one.
46
47       encrypt($message)
48           Encrypt a message.  This uses the key stored in the current
49           Crypt::CipherSaber object.  It generates a 10-byte random IV
50           (Initialization Vector) automatically, as defined in the RC4
51           specification.  This returns a string containing the encrypted
52           message.
53
54           Note that the encrypted message may contain unprintable characters,
55           as it uses the extended ASCII character set (valid numbers 0
56           through 255).
57
58       decrypt($message)
59           Decrypt a message.  For the curious, the first ten bytes of an
60           encrypted message are the IV, so this must strip it off first.
61           This returns a string containing the decrypted message.
62
63           The decrypted message may also contain unprintable characters, as
64           the CipherSaber encryption scheme handles binary filesIf this is
65           important to you, be sure to treat the results correctly.
66
67       crypt($iv, $message)
68           If you wish to generate the IV with a more cryptographically secure
69           random string (at least compared to Perl's builtin "rand()"
70           operator), you may do so separately, passing it to this method
71           directly.  The IV must be a ten-byte string consisting of
72           characters from the extended ASCII set.
73
74           This is generally only useful for encryption, although you may
75           extract the first ten characters of an encrypted message and pass
76           them in yourself.  You might as well call decrypt(), though.  The
77           more random the IV, the stronger the encryption tends to be.  On
78           some operating systems, you can read from /dev/random.  Other
79           approaches are the Math::TrulyRandom module, or compressing a file,
80           removing the headers, and compressing it again.
81
82       fh_crypt(\*INPUT, \*OUTPUT, ($iv))
83           For the sake of efficiency, Crypt::CipherSaber can filehandles.
84           It's not super brilliant, but it's relatively fast and sane.  Pass
85           in a reference to the input file handle and the output filehandle.
86           If your platform needs to use "binmode()", this is your
87           responsibility.  It is also your responsibility to close the files.
88
89           You may also pass in an optional third parameter, an IV.  There are
90           three possibilities here.  If you pass no IV, "fh_crypt()" will
91           pull the first ten bytes from the input filehandle and use that as
92           an IV.  This corresponds to decryption.  If you pass in an IV of
93           your own, it will use that when encrypting the file.  If you pass
94           in the value 1, it will generate a new, random IV for you.  This
95           corresponds to an encryption.
96
98       Copyright (C) 2000 - 2001, 2005 chromatic
99
100       This library is free software; you can use, modify, and redistribute it
101       under the same terms as Perl 5.8.x itself.
102

AUTHOR

104       chromatic "chromatic at wgz dot org"
105
106       thanks to jlp for testing, moral support, and never fearing the icky
107       details and to the fine folks at http://perlmonks.org/.
108
109       Additional thanks to Olivier Salaun and the Sympa project
110       (http://www.sympa.org) for testing.
111

SEE ALSO

113       the CipherSaber home page at <http://ciphersaber.gurus.com/>
114
115       perl(1), rand().
116
117
118
119perl v5.12.0                      2010-04-30             Crypt::CipherSaber(3)
Impressum