private static void FindOtherKey(string keyFilePath) { var serializer = new SimpleModulusKeySerializer(); serializer.Deserialize(keyFilePath, out uint[] modkey, out uint[] cryptKey, out uint[] xorKey); var generator = new SimpleModulusKeyGenerator(); var otherCryptKey = generator.FindOtherKey(modkey, cryptKey); var file = new FileInfo(keyFilePath); var otherFileName = GetOtherFileName(file.Name); var otherFilePath = Path.Combine(file.DirectoryName, otherFileName); Console.WriteLine($"Calculation successful. To save the calculated key to file '{otherFilePath}' press any key"); Console.ReadKey(true); serializer.Serialize(otherFilePath, modkey, otherCryptKey, xorKey); Console.WriteLine("Key saved"); }
private static void FindOtherKey(string keyFilePath) { var serializer = new SimpleModulusKeySerializer(); if (serializer.TryDeserialize(keyFilePath, out var modulusKey, out var cryptKey, out var xorKey)) { Console.WriteLine($"Loaded Key:"); Console.WriteLine($" Modulus: {string.Join(", ", modulusKey.Select(k => k.ToString()))}"); Console.WriteLine($" Crypt: {string.Join(", ", cryptKey.Select(k => k.ToString()))}"); Console.WriteLine($" XOR: {string.Join(", ", xorKey.Select(k => k.ToString()))}"); var generator = new SimpleModulusKeyGenerator(); var otherCryptKey = generator.FindOtherKey(modulusKey, cryptKey); var file = new FileInfo(keyFilePath); var otherFileName = GetOtherFileName(file.Name); var otherFilePath = file.DirectoryName is null ? otherFileName : Path.Combine(file.DirectoryName, otherFileName); Console.WriteLine($"Calculated Crypt Key: {string.Join(", ", otherCryptKey.Select(k => k.ToString()))}"); Console.WriteLine($"To save the calculated key file '{otherFilePath}' press any key"); Console.ReadKey(true); serializer.Serialize(otherFilePath, modulusKey, otherCryptKey, xorKey); Console.WriteLine("Key saved"); }