我使用Azure密钥库客户端和加密客户端加密数据,我能够加密数据,现在我更改了密钥版本,并尝试解密数据,但新版本无法解密数据,
var keyName = "bcdfed";
var keyVaultUrl = "https://abcd.vault.azure.net";
var token = new DefaultAzureCredential();
var keyClient = new KeyClient(new Uri(keyVaultUrl), token);
var azureKey = await keyClient.GetKeyAsync(keyName);
var cryptographyClient = keyClient
.GetCryptographyClient(azureKey.Value.Name, azureKey.Value.Properties.Version);
var inputValue = "input some value";
byte[] input = Encoding.UTF8.GetBytes(inputValue);
var encryptionResult = await cryptographyClient
.EncryptAsync(EncryptionAlgorithm.RsaOaep, input);
var encryptedString = Convert.ToBase64String(encryptionResult.Ciphertext);
byte[] encryptedResultByte = Convert.FromBase64String(encryptedString);
await cryptographyClient
.DecryptAsync(EncryptionAlgorithm.RsaOaep, encryptedResultByte);
我尝试使用新版本解密数据
1条答案
按热度按时间tjrkku2a1#
1.* 在Azure中创建密钥保险库。*
1.* 使用下面提到的密钥策略创建密钥。*
key identifier
和key name
。*输出:*
是的,我们使用了新版本,能够解密。*