DEV Community

Roger Doss
Roger Doss

Posted on

Perl Stream Cipher

A stream cipher is a type of cipher that encrypts each bit. I used this design to implement a cipher in Perl that uses SHA-3 as the basis for the pseudo-random bits. The code gets a random set of numbers as a key from random.org, and then encrypts them using a password on disk for key storage. The on disk algorithm is AES.

The stream cipher then uses the random key to encrypt by xor function of each byte of the plain text, to create the cipher text. When it needs more bits, it re-hashes the key using SHA-3.

The algorithm can be run using:

perl -I. ssc_main.pl input.plain output.cipher

The implementation is here:

StreamCipher

Top comments (0)