nitroglycerin v0.2.0 Nitroglycerin

A module for encrypting and decrypting the contents of an IO device, eg. a file, using a one-time pad.

Summary

Functions

Decrypts source_io with the given pad (a Nitroglycerin.Pad) and outputs the decrypted bytes to the target_io

Encrypts source_io with the given pad (a Nitroglycerin.Pad) and outputs the encrypted bytes to the target_io

Functions

decrypt!(source_io, pad, target_io)

Decrypts source_io with the given pad (a Nitroglycerin.Pad) and outputs the decrypted bytes to the target_io.

both source_io and target_io should be IO.Streams that can be read and written with IO.binread and IO.binwrite.

Returns the number of bytes left of the pad.

Examples

> input = File.open!("input.txt.nitro")
> pad = Nitroglycerin.Pad.from_path("random.pad")
> output = File.open!("output.txt", [:write])
> Nitroglycerin.decrypt!(input, pad, output)
15643
encrypt!(source_io, pad, target_io)

Encrypts source_io with the given pad (a Nitroglycerin.Pad) and outputs the encrypted bytes to the target_io.

both source_io and target_io should be IO.Streams that can be read and written with IO.binread and IO.binwrite.

Returns the number of bytes left of the pad.

Examples

> input = File.open!("input.txt")
> pad = Nitroglycerin.Pad.from_path("random.pad")
> output = File.open!("output.txt.nitro", [:write])
> Nitroglycerin.encrypt!(input, pad, output)
15643