| Visual Basic (Declaration) | |
|---|---|
Public Function New( _ ByVal certificate As X509Certificate2 _ ) | |
| C# | |
|---|---|
public RSAPrivateKey( X509Certificate2 certificate ) | |
Parameters
- certificate
Library/Library.Test/TestRSACrypto.cs
| C# | Copy Code |
|---|---|
byte[] rawdata = new byte[8001]; new Random().NextBytes(rawdata); byte[] cypher; using (RSAPublicKey publicKey = new RSAPublicKey(TestCertPublicKey())) cypher = publicKey.Encrypt(rawdata); using (RSAPrivateKey privateKey = new RSAPrivateKey(TestCertPrivateKey())) Assert.AreEqual(rawdata, privateKey.Decrypt(cypher)); | |
| VB.NET | Copy Code |
|---|---|
Dim rawdata As Byte() = New Byte(8001) {} New Random().NextBytes(rawdata) Dim cypher As Byte() Using publicKey As New RSAPublicKey(TestCertPublicKey()) cypher = publicKey.Encrypt(rawdata) End Using Using privateKey As New RSAPrivateKey(TestCertPrivateKey()) Assert.AreEqual(rawdata, privateKey.Decrypt(cypher)) End Using | |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
RSAPrivateKey ClassRSAPrivateKey Members
Overload List