private void SendEncryptedSessionKeyToClient_Click(object sender, RoutedEventArgs e) { Logger.Info("Starting session keys encrypting ..."); var sessionKeys = File.ReadAllText(ServerSessionKeysPath).Split(',').ToList(); var openRsaParameters = File.ReadAllText(OpenRsaParametersPath).Split(','); var encryptedSessionKeys = sessionKeys.Select(x => Rsa.ModPow(x, openRsaParameters[0], openRsaParameters[1])); encryptedSessionKeys.ToList().ForEach(x => Logger.Info("32 bytes has been encrypted: " + x)); File.WriteAllText(ClientEncryptedSessionKeysPath, String.Join(",", encryptedSessionKeys)); Logger.Info("Finishing session keys encrypting ..."); }
private void DecryptSessionKey_Click(object sender, RoutedEventArgs e) { Logger.Info("Starting session keys decrypting ..."); var encryptedSessionKeys = File.ReadAllText(ClientEncryptedSessionKeysPath).Split(',').ToList(); var openRsaParameters = File.ReadAllText(OpenRsaParametersPath).Split(','); var privateExponent = File.ReadAllText(ClientPrivateExponentPath); var decryptedSessionKeys = encryptedSessionKeys.Select(x => Rsa.ModPow(x, privateExponent, openRsaParameters[1])); decryptedSessionKeys.ToList().ForEach(x => Logger.Info("32 bytes has been decrypted: " + x)); File.WriteAllText(ClientDecryptedSessionKeysPath, String.Join(",", decryptedSessionKeys)); Logger.Info("Finishing session keys decrypting ..."); }