![]() Put_Line ( "Playn ->" & Text ) Text := crypt ( Text, Key ) Ada. This will be our 'key' that will allow us to encrypt and decrypt the message. It works like this: First, choose some text that you want to encrypt. Get_Line Key : modulo26 := 3 - Default key from "Commentarii de Bello Gallico" shift cipher begin - encryption main program Ada. The Caesar cipher is one of the earliest and simplest ciphers that were invented. The ciphertext alphabet may be a shifted, reversed, mixed or deranged version of the plaintext alphabet. ' z ' => Ciph ( I ) := Character ( modulo26 ( Playn ( I ) + Key ), ' a ') when others => Ciph ( I ) := Playn ( I ) end case end loop return Ciph end crypt Text : String := Ada. Input- ABCDX Output- FGHIZ Input1-Hi Hell Output1- jk Lipp when the last alphabet X needs to be shifted 5 times forward but the aphabet end at Z,X is. A monoalphabetical substitution cipher uses a fixed substitution over the entire message. is called a shift code because we can think of shifting the alphabet over a spaces. In cryptography the shift code, or Caesar cipher, is one of the simplest and most widely known encryption techniques. ' Z ' => Ciph ( I ) := Character ( modulo26 ( Playn ( I ) + Key ), ' A ') when ' a '. convenient to assign numbers to these letters, and the most natural. With Ada.Text_IO procedure Caesar is type modulo26 is modulo 26 function modulo26 ( Character : Character Output : Character ) return modulo26 is begin return modulo26 ( Character ' Pos ( Character ) + Character ' Pos ( Output )) end modulo26 function Character ( Val : in modulo26 Output : Character ) return Character is begin return Character ' Val ( Integer ( Val ) + Character ' Pos ( Output )) end Character function crypt ( Playn : String Key : modulo26 ) return String is Ciph : String ( Playn ' Range ) begin for I in Playn ' Range loop case Playn ( I ) is when ' A '.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |