static void Main(string[] args) { Console.WriteLine("..........File Bytes........."); string file = @"D:\Atbash.exe"; //File Will Be Encrypted <--------------- string key = "abcde"; byte[] fileBytes = File.ReadAllBytes(file); for (int i = 0; i <= fileBytes.Length - 1; i++) { Console.Write(fileBytes[i] + " "); } Console.WriteLine("\n \n"); Console.WriteLine("..........File Encrypted Bytes........."); byte[] fileEncryptedBytes = EncryptionClass.Encryption(file, key); File.WriteAllBytes(@"D:\AtbashEncrypt.exe", fileEncryptedBytes); string fileE = @"D:\AtbashEncrypt.exe"; //You want this file name in Excute programe for (int i = 0; i <= fileEncryptedBytes.Length - 1; i++) { //File Encrypted Byte Copy output To paste in Excute Programe Console.Write(fileEncryptedBytes[i] + " "); } Console.WriteLine("\n \n"); Console.WriteLine("..........File Decrypted Bytes........."); byte[] fileDecryptedBytes = EncryptionClass.Decryption(fileE, key); for (int i = 0; i <= fileDecryptedBytes.Length - 1; i++) { Console.Write(fileDecryptedBytes[i] + " "); } Console.ReadKey(); }
public static void Main(string[] args) { WorkWithFileClass workWithFileClass = new WorkWithFileClass(); WorkWithConsoleClass workWithConsoleClass = new WorkWithConsoleClass(); EncryptionClass encryptionClass = new EncryptionClass(); var inputMessage = workWithFileClass.ReadFile(); int m = workWithFileClass.GetAlphabetLength(); int n = workWithConsoleClass.ReadNFromConsole(); while (encryptionClass.GCD(n, m) != 1) { n = workWithConsoleClass.ReadAnotherNFromConsole(); } int k = workWithConsoleClass.ReadKFromConsole(); var numCodeOfAlphabet = workWithFileClass.GetNumCodeOfAlphabet(); var encryptedMessage = encryptionClass.Encryption(inputMessage, numCodeOfAlphabet, n, k, m); var decryptedMessage = encryptionClass.Decryption(encryptedMessage, numCodeOfAlphabet, k, n, m); workWithFileClass.OutputResultToFile(encryptedMessage, decryptedMessage); }
public static void Main(string[] args) { WorkWithConsoleClass workWithConsoleClass = new WorkWithConsoleClass(); WorkWithFileClass workWithFileClass = new WorkWithFileClass(); EncryptionClass encryptionClass = new EncryptionClass(); CongruentialGeneratorClass congruentialGeneratorClass = new CongruentialGeneratorClass(); int a = workWithConsoleClass.InputA(); int c = workWithConsoleClass.InputC(); int startValue = workWithConsoleClass.InputStartValue(); int m = workWithConsoleClass.InputM(); var inputFile = workWithFileClass.ReadFile(); var keyWord = congruentialGeneratorClass.CongruentialGenerator(a, c, m, startValue, inputFile.Length); var binaryCodeOfAlphabet = workWithFileClass.GetBinaryCodeOfAlphabet(); var decimalCodeAndLetterOfAlphabet = workWithFileClass.GetDecimalCodeAndLetterOfAlphabet(); var encryptedMessage = encryptionClass.Encryption(inputFile, keyWord, binaryCodeOfAlphabet, decimalCodeAndLetterOfAlphabet); var decryptedMessage = encryptionClass.Decryption(encryptedMessage, keyWord, binaryCodeOfAlphabet, decimalCodeAndLetterOfAlphabet); workWithFileClass.OutputResultToFile(encryptedMessage, decryptedMessage); }
public static void Main(string[] args) { WorkWithFileClass workWithFileClass = new WorkWithFileClass(); EncryptionClass encryptionClass = new EncryptionClass(); var keyPairs = encryptionClass.CreateKeyPairs(workWithFileClass.ReadAlphabetFile()); var encryptedMessage = encryptionClass.Encryption(workWithFileClass.ReadFile(), keyPairs); var decryptedMessage = encryptionClass.Decryption(encryptedMessage, keyPairs); workWithFileClass.OutputResultToFile(encryptedMessage, decryptedMessage); }
public static void Main(string[] args) { WorkWithFileClass workWithFileClass = new WorkWithFileClass(); WorkWithConsole workWithConsole = new WorkWithConsole(); EncryptionClass encryptionClass = new EncryptionClass(); var keyWord = workWithConsole.InputKeyWordFromConsole(); var encryptedMessage = encryptionClass.Encryption(workWithFileClass.ReadFile(), keyWord, workWithFileClass.CreateVigenereTableFromFile()); var decryptedMessage = encryptionClass.Decryption(encryptedMessage, keyWord, workWithFileClass.CreateVigenereTableFromFile()); workWithFileClass.OutputResultToFile(encryptedMessage, decryptedMessage); }