DEV Community

Roger Doss
Roger Doss

Posted on

1

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay