From: adacrypt on 15 Jun 2010 05:44 WITH Ada.Text_IO; PROCEDURE Batch_Encryption_Program_Mark_1 IS _____________________________________________________________________ --| A demonstration of file handling i.e. reading in from a batch file of plaintext --| _____________________________________________________________________ MaxName : Constant Positive := 80; SUBTYPE NameRange IS Positive RANGE 1 .. MaxName; InFileName : String(NameRange) :=(OTHERS => '#'); OutFileName: String(NameRange) :=(OTHERS => '#'); InNameLength: NameRange; OutNameLength: NameRange; InData: Ada.Text_IO.File_Type; OutData: Ada.Text_IO. File_Type; --NextCh: Character;-- That will be the variable name of each character read in BEGIN -- Batch_Encryption_Program_Mark_1 -- get input file name and open it Ada.Text_IO.Put(Item => " PLease enter the name of the file to encrypt >"); Ada.Text_IO.New_Line(2); Ada.Text_IO.Put(Item => " "); Ada.Text_IO.Get_Line(Item => InFileName, Last=> InNameLength); Ada.Text_IO.New_Line; Ada.Text_IO.Open(File => Indata, Mode => Ada.Text_IO.In_File,Name => InFileName(1 .. InNameLength)); -------------------------------------------------------------- This declaration above will get you any file in your directory the file must exist first of all and if theres a file extension it must be quoted. This simple declaration is all that is needed to get you started encrypting a file of plaintext it can be repeated in all programs as a standard declaration every time. This an excerpt from Ada-95 Problem Solving and Program Design Feldman and Koffman. It makes file handling very easy works every time try it ! An invaluable exercise is to work example 10.10 on P. 451 this worked example gives complete cource code - makes a copy file of an existing external file - the application to cryptography is obvious. yours humbly - adacrypt
From: Mok-Kong Shen on 15 Jun 2010 06:12 adacrypt worte: >...... - makes a copy file of an > existing external file - the application to cryptography is obvious. � I don't understand this at all. Could you elaborate on your point? M. K. Shen
From: adacrypt on 15 Jun 2010 07:18 On Jun 15, 11:12 am, Mok-Kong Shen <mok-kong.s...(a)t-online.de> wrote: > adacrypt worte: > > >...... - makes a copy file of an > > existing external file - the application to cryptography is obvious. > > I don't understand this at all. Could you elaborate on your point? > > M. K. Shen This is about a rather tricky operation in programming that arises repeatedly in cryptography in every cipher computer program. The author of the book is not into cryptography in any way - the example in the book reads in an existing file of plaintext ostensibly for the puropose of copying it and outputting it as a copy-file of the original - the object of the example is to introduce the reader to the procedure of naming and calling external files from within a program - (remember this is a pedagocically orientated syle of text book ) - the example may seem trivial i.e. copying a file should be easy by a number of other methods but that is not what is on the radar. The objective is in file handling of files of plaintext and ciphertext. The suggestion by me is that the same example is useful to crypto students in that an adaptation to cryptography is obvious i.e. read in the character of plaintext for encryption (from a prepared batch file) , encipher it and then output it to a growing file of ciphertext, Each character is dealt with one by one in a program loop.. File handling i.e. reading in from and writing out to external files is one of the more difficult operations in programming and there is evidence that some crypto users are skirting it by reading in binary directly from the key board which is not a professional solution or indeed a very reliable and efficient one (error prone ) whatever they may say in its defence - Regards - adacrypt
From: Bruce Stephens on 15 Jun 2010 07:35 adacrypt <austin.obyrne(a)hotmail.com> writes: [...] > File handling i.e. reading in from and writing out to external files > is one of the more difficult operations in programming No it isn't. > and there is evidence that some crypto users are skirting it by > reading in binary directly from the key board Nobody has suggested doing that. [...]
From: adacrypt on 15 Jun 2010 08:01 On Jun 15, 11:12 am, Mok-Kong Shen <mok-kong.s...(a)t-online.de> wrote: > adacrypt worte: > > >...... - makes a copy file of an > > existing external file - the application to cryptography is obvious. > > I don't understand this at all. Could you elaborate on your point? > > M. K. Shen Also, I forgot to say that this modus operandi (reading in from batch files in Ada-95) is at the core of several ciphers that I have written - I would never consider changing it because it is so logical and transparent - my encryption program is in essence a pair of large nested loops, the outer loops calls in a character from the externally prepared batch file in my folder(directory), the inner loop then transforms this character by operating on its ASCII denary value in a number of ways until the transformation into ciphertext is completed in one pass of the inner loop and it then writes (outputs) the ciphertext to a growing file of ciphertext in another named file in my directory (folder). The loop is controlled i.e. terminated by the Ada End_of_Line command that terminates the inside loop (transforming the current character) and finally by the End_of_File command that terminates the outer loop when the last character has been read in and encrypted by the inside loop. This model is so good that I cannot think of anything better as an encryption program. Decryption is done in symmetric fashion by another identical pair of loops at Bob's end. ( in passing, the mathematics may be either symmetric or asymmetric) I have found this language so good for cryptography that I want to recommend it to everybody else who might be interested in it. Cheers - Adacrypt.
|
Next
|
Last
Pages: 1 2 Prev: Need some simple bijective mappings Next: Best practice for password hashing (proposal) |