private string GetLink(string id) { try { var key = _configurationProvider.ReadConfigurationObject(ConfigurationConstants.AesEncryptionKey); byte[] keyBytes; if (key == null) { var bytes = new byte[32]; RandomNumberGenerator.Fill(bytes); _configurationProvider.AddConfigurationObject(ConfigurationConstants.AesEncryptionKey, AESCypher.ToString(bytes)); keyBytes = bytes; } else { keyBytes = AESCypher.ToBytes(key.Value); } var(cipher, nonce, tag) = AESCypher.Encrypt(id, keyBytes); return($"{Request.Scheme}://{Request.Host}/" + $"{ViewConstants.AccountController}/{ViewConstants.RegistrationAction}" + $"?Cipher={cipher}&Tag={tag}&Nonce={nonce}"); } catch (Exception e) { _logger.LogError(e, "Failed to create invitation link."); } return(string.Empty); }
public void SaveConfigObject([FromBody] ConfigurationObjectViewModel viewModel) { ConfigurationObject model = GetModelFromViewModel(viewModel); _configurationProvider.AddConfigurationObject(model.Name, model.Value); }