|
| 1 | +--- |
| 2 | +title: "RSA.EncryptValue and RSA.DecryptValue are obsolete" |
| 3 | +description: Learn about the .NET 8 breaking change in cryptography where RSA.EncryptValue and RSA.DecryptValue are marked obsolete. |
| 4 | +ms.date: 01/24/2023 |
| 5 | +--- |
| 6 | +# RSA.EncryptValue and RSA.DecryptValue are obsolete |
| 7 | + |
| 8 | +The following methods are obsolete in .NET 8 (and later versions): |
| 9 | + |
| 10 | +- <xref:System.Security.Cryptography.RSA.EncryptValue(System.Byte[])?displayProperty=nameWithType> |
| 11 | +- <xref:System.Security.Cryptography.RSA.DecryptValue(System.Byte[])?displayProperty=nameWithType> |
| 12 | +- <xref:System.Security.Cryptography.RSACryptoServiceProvider.EncryptValue(System.Byte[])?displayProperty=nameWithType> |
| 13 | +- <xref:System.Security.Cryptography.RSACryptoServiceProvider.DecryptValue(System.Byte[])?displayProperty=nameWithType> |
| 14 | + |
| 15 | +All references to these methods will result in a [SYSLIB0048](../../../../fundamentals/syslib-diagnostics/syslib0048.md) warning at compile time. |
| 16 | + |
| 17 | +## Previous behavior |
| 18 | + |
| 19 | +Previously, code could call the [affected methods](#affected-apis) without any compilation warnings. However, they threw a <xref:System.NotSupportedException> at run time. |
| 20 | + |
| 21 | +## New behavior |
| 22 | + |
| 23 | +Starting in .NET 8, calling the [affected methods](#affected-apis) produces a `SYSLIB0048` compilation warning. |
| 24 | + |
| 25 | +## Version introduced |
| 26 | + |
| 27 | +.NET 8 Preview 1 |
| 28 | + |
| 29 | +## Type of breaking change |
| 30 | + |
| 31 | +This change can affect [source compatibility](../../categories.md#source-compatibility). |
| 32 | + |
| 33 | +## Reason for change |
| 34 | + |
| 35 | +The affected methods were never implemented and always threw a <xref:System.NotSupportedException>. Since the purpose of these methods is unclear and they shouldn't be called, they were marked as obsolete. |
| 36 | + |
| 37 | +## Recommended action |
| 38 | + |
| 39 | +To encrypt or decrypt with RSA, use <xref:System.Security.Cryptography.RSA.Encrypt%2A?displayProperty=nameWithType> or <xref:System.Security.Cryptography.RSA.Decrypt%2A?displayProperty=nameWithType> instead. |
| 40 | + |
| 41 | +## Affected APIs |
| 42 | + |
| 43 | +- <xref:System.Security.Cryptography.RSA.EncryptValue(System.Byte[])?displayProperty=fullName> |
| 44 | +- <xref:System.Security.Cryptography.RSA.DecryptValue(System.Byte[])?displayProperty=fullName> |
| 45 | +- <xref:System.Security.Cryptography.RSACryptoServiceProvider.EncryptValue(System.Byte[])?displayProperty=fullName> |
| 46 | +- <xref:System.Security.Cryptography.RSACryptoServiceProvider.DecryptValue(System.Byte[])?displayProperty=fullName> |
0 commit comments