nitroglycerin v0.2.1 Nitroglycerin.Pad

A struct & constructor for holding the key details about a one-time pad file.

Summary

Functions

Generate a completed Nitroglycerin.Pad from the pathname of a pad file

Record that some of a pad has been used

Functions

from_path(pad_path)

Generate a completed Nitroglycerin.Pad from the pathname of a pad file.

If the pad file doesn’t exist, this struct will form the basis of the one that will be written.

Examples

> Nitroglycerin.Pad.from_path("random.pad")
%Nitroglycerin.Pad{
  path: "random.pad",
  usage_path: "random.pad.usage",
  size: 12345678,
  io: #PID<0.0.0>,
  next_index: 0,
}
used!(pad, used_up_to)

Record that some of a pad has been used.

Assumes that you have used used_up_to bytes from the start of the given pad. If a number smaller than the one already stored is given then the largest will be left in the pad usage file.

Examples

Record that the first 1024 bytes have been used:

> Nitroglycerin.Pad.used!(pad, 1024)

Ensure a pad has been written to disk:

> Nitroglycerin.Pad.used!(pad, 0)