private void SetNewRsaKeys(Message message) { var fileKey = message.StringMessage; var privateFilePath = CreatePrivateKeyFileName(); var publicFilePath = CreatePublicKeyFileName(); SHA1 hash = SHA1.Create(); CryptoController crypto = new CryptoController(); try { crypto.CreateAndSaveRsaParameters(publicFilePath, privateFilePath, fileKey); } catch (Exception ex) { SendResult(false, ex.Message); return; } var keyHash = ByteToStringConverter(hash.ComputeHash(StringToByteConverter(fileKey))); if (_dbController.GetPublicKeyPath(_userId) == null) { _dbController.AddRsaKey(_userId, privateFilePath, publicFilePath, keyHash); } else { _dbController.UpdateRsaKey(_userId, privateFilePath, publicFilePath, keyHash); } SendResult(true); }