Skip to content

Commit d80851c

Browse files
authored
Improve Wrap/Unwrap sample (Azure#37000)
* Update Sample6_WrapUnwrap.md Show the base64 encoded key as it was shown upon creation to compare apples to apples * Show the original value in base64
1 parent 2c914f8 commit d80851c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample6_WrapUnwrap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Now unwrap the encrypted key. Note that the same algorithm must always be used f
6161

6262
```C# Snippet:KeysSample6UnwrapKey
6363
UnwrapResult unwrapResult = cryptoClient.UnwrapKey(KeyWrapAlgorithm.RsaOaep, wrapResult.EncryptedKey);
64-
Debug.WriteLine($"Decrypted data using the algorithm {unwrapResult.Algorithm}, with key {unwrapResult.KeyId}. The resulting decrypted data is {Encoding.UTF8.GetString(unwrapResult.Key)}");
64+
Debug.WriteLine($"Decrypted data using the algorithm {unwrapResult.Algorithm}, with key {unwrapResult.KeyId}. The resulting decrypted data is {Convert.ToBase64String(unwrapResult.Key)}");
6565
```
6666

6767
[DefaultAzureCredential]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md

sdk/keyvault/Azure.Security.KeyVault.Keys/tests/samples/Sample6_WrapUnwrap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void WrapUnwrapSync()
5555

5656
#region Snippet:KeysSample6UnwrapKey
5757
UnwrapResult unwrapResult = cryptoClient.UnwrapKey(KeyWrapAlgorithm.RsaOaep, wrapResult.EncryptedKey);
58-
Debug.WriteLine($"Decrypted data using the algorithm {unwrapResult.Algorithm}, with key {unwrapResult.KeyId}. The resulting decrypted data is {Encoding.UTF8.GetString(unwrapResult.Key)}");
58+
Debug.WriteLine($"Decrypted data using the algorithm {unwrapResult.Algorithm}, with key {unwrapResult.KeyId}. The resulting decrypted data is {Convert.ToBase64String(unwrapResult.Key)}");
5959
#endregion
6060

6161
DeleteKeyOperation operation = keyClient.StartDeleteKey(rsaKeyName);

0 commit comments

Comments
 (0)