private static bool ValidateSourceData(EncryptionInput input) { return(input != null && !string.IsNullOrEmpty(input.CertName) && !string.IsNullOrEmpty(input.CertStore) && input.Data != null && input.Key != null && input.IV != null); }
public IActionResult UploadConfig([FromForm] EncryptionInput input) { if (input == null && string.IsNullOrEmpty(input.FileName)) { return(BadRequest("缺少文件名")); } var files = Request.Form.Files; var key = $"_{DateTime.Now:yyyyMMddHHmmss}_{Guid.NewGuid()}"; if (!_cache.TryGetValue(input.FileName + key, out byte[] cacheEntry))
private IDictionary <string, string> DecryptConfiguration(EncryptionInput input) { var encryptUtil = new ConfigurationEncryptionUtility(); var cert = encryptUtil.GetCertificate(input.CertStore, input.CertName); if (cert == null) { throw new ArgumentException($"Certificate not found"); } var decryptedOutput = encryptUtil.Decrypt(cert, input); var jsonConfigurationFileParser = new JsonConfigurationFileParser(); IDictionary <string, string> deserializedData = null; using (MemoryStream stream = new MemoryStream(decryptedOutput, 0, decryptedOutput.Length)) { deserializedData = jsonConfigurationFileParser.Parse(stream); } return(deserializedData); }