Crypt::CipherSaber(3pm) | User Contributed Perl Documentation | Crypt::CipherSaber(3pm) |
Crypt::CipherSaber - Perl module implementing CipherSaber encryption.
use Crypt::CipherSaber; my $cs = Crypt::CipherSaber->new('my sad secret key'); my $coded = $cs->encrypt('Here is a secret message for you'); my $decoded = $cs->decrypt($coded); # encrypt from and to a file open my $in, 'secretletter.txt' or die "Can't open infile: $!"; open my $out, '>', 'secretletter.cs1' or die "Can't open outfile: $!"; binmode $in; binmode $out; $cs->fh_crypt($in, $out, 1); # decrypt from and to a file open my $in, 'secretletter.txt' or die "Can't open infile: $!"; open my $out, '>', 'secretletter.cs1' or die "Can't open outfile: $!"; binmode $in; binmode $out; $cs->fh_crypt($in, $out);
The Crypt::CipherSaber module implements CipherSaber encryption, described at <http://ciphersaber.gurus.com/>. It is simple, fairly speedy, and relatively secure algorithm based on RC4. Relatively, given RC4.
Encryption and decryption are done based on a secret key, which must be shared with all intended recipients of a message.
Note that the encrypted message may contain unprintable characters, as it uses the extended ASCII character set (valid numbers 0 through 255).
The decrypted message may also contain unprintable characters, as the CipherSaber encryption scheme handles binary filesIf this is important to you, be sure to treat the results correctly.
This is generally only useful for encryption, although you may extract the first ten characters of an encrypted message and pass them in yourself. You might as well call decrypt(), though. The more random the IV, the stronger the encryption tends to be. On some operating systems, you can read from /dev/random. Other approaches are the Math::TrulyRandom module, or compressing a file, removing the headers, and compressing it again.
You may also pass in an optional third parameter, an IV. There are three possibilities here. If you pass no IV, "fh_crypt()" will pull the first ten bytes from the input filehandle and use that as an IV. This corresponds to decryption. If you pass in an IV of your own, it will use that when encrypting the file. If you pass in the value 1, it will generate a new, random IV for you. This corresponds to an encryption.
Copyright (C) 2000 - 2015 chromatic
This library is free software; you can use, modify, and redistribute it under the same terms as Perl 5.20.x itself.
chromatic "chromatic at cpan dot org"
thanks to jlp for testing, moral support, and never fearing the icky details and to the fine folks at PerlMonks <http://perlmonks.org/>.
Additional thanks to Olivier Salaun and the Sympa project <http://www.sympa.org> for testing.
the CipherSaber home page at <http://ciphersaber.gurus.com/>
perl(1), rand().
2017-04-04 | perl v5.24.1 |