From: adacrypt on
This program is used to generate the set of N's as moduli for any
given messsage length. The program is intended for use when using the
printable subset of ASCII <= the elements no's 32 to 126 inclusively.
Should adapt easily in C.

WITH Ada.Text_IO;
WITH Ada.Integer_Text_IO;
PROCEDURE Make_Moduli_Program_Mark_0 is
-----------------------------------------------------------------------
--| This program does a dry test run, it validates the proposed range
of Moduli
--| for a given X on all possible pairings of (Plaintext + Key) and
--| makes sure it will work in practice when it is later programmed
--| into a reliable working program.
--| Copyright © 2009 Austin O'Byrne.
--| Last modified February 2010.
-----------------------------------------------------------------------
Plaintext : Integer;
Key : Integer;
Jointvalue : Integer;
Modulus : Integer;
Residue : Integer;
Ciphertext : Integer;
Linenumber : Integer;
View : Character;

X: CONSTANT Integer:=63;--demonstrates minumum start value
--user should adjust upwards =>Messagelength
+ 63.

BEGIN -- Make_Moduli_Program_Mark_0
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (Item => " PlainText | Joint | Current |
Residue = | CipherText = |");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (Item => " and Key | Value | Modulus N | Joint
Val REM N | Residue - N |");
Ada.Text_IO.New_Line(1);
Ada.Text_IO.Put (Item => "
------------------------------------------------------------------------------");
Ada.Text_IO.New_Line;
View:=' '; -- initialised to stop error messages
Linenumber:= 0;

FOR N in (X+127) .. 2*(X+32) LOOP
Modulus := N;
FOR J in X+32 .. X+126 LOOP --this is the particular slice of the
universal
Key := J; -- denary value of Key
FOR I in X+32 .. X+126 LOOP--Modulus must be 1 greater than max Key
& max plaintext.
Plaintext:= I; -- denary value of Plaintext
Linenumber:= Linenumber + 1;
Jointvalue := Key + Plaintext;
Residue := Jointvalue REM (Modulus);
CipherText:= Residue - Key;
Ada.Integer_Text_Io.Put(Item => Plaintext, Width => 5);
Ada.Text_Io.Put(Item => "+");
Ada.Integer_Text_Io.Put(Item => Key, Width => 2);
Ada.Integer_Text_Io.Put (Item => Jointvalue, Width => 10);
Ada.Integer_Text_Io.Put(Item => N,Width => 10);
Ada.Integer_Text_Io.Put(Item => Jointvalue REM N, Width =>16);
Ada.Integer_Text_Io.Put(Item => Jointvalue REM N, Width => 18);
Ada.Text_Io.Put(Item => " - ");
Ada.Integer_Text_Io.Put(Item => Key, Width => 2);
Ada.Text_Io.Put(Item => "=");
Ada.Integer_Text_Io.Put(Item => CipherText, Width =>4);
Ada.Text_Io.New_Line;
-- IF Linenumber REM 95 = 0 then --halts program for user to view.
-- Ada.Text_IO.Put --
-- (Item => " # - press any key /return to continue #"); --
-- Ada.Text_IO.Get(Item => View); --
-- END IF; --
END LOOP;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put(Item =>"
-----------------------------------------------------------");
Ada.Text_IO.New_Line;
END LOOP;
END LOOP;
Ada.Text_IO.New_Line;
END Make_Moduli_Program_Mark_0;

----------------------------------------------