Creates the key from the information provided
Syntax
Example
Library/Library.Test/TestRSACrypto.cs
C# | Copy Code |
---|
RSAPublicKey pk = new RSAPrivateKey().PublicKey;
string xml = pk.ToXml();
RSAPublicKey copy = RSAPublicKey.FromXml(xml);
Assert.AreEqual(xml, copy.ToXml());
byte[] bytes = pk.ToArray();
Assert.AreEqual(148, bytes.Length);
copy = RSAPublicKey.FromBytes(bytes);
Assert.AreEqual(bytes, copy.ToArray());
copy = RSAPublicKey.FromParameters(pk.ExportParameters());
Assert.AreEqual(bytes, copy.ToArray()); |
VB.NET | Copy Code |
---|
Dim pk As RSAPublicKey = New RSAPrivateKey().PublicKey
Dim xml As String = pk.ToXml()
Dim copy As RSAPublicKey = RSAPublicKey.FromXml(xml)
Assert.AreEqual(xml, copy.ToXml())
Dim bytes As Byte() = pk.ToArray()
Assert.AreEqual(148, bytes.Length)
copy = RSAPublicKey.FromBytes(bytes)
Assert.AreEqual(bytes, copy.ToArray())
copy = RSAPublicKey.FromParameters(pk.ExportParameters())
Assert.AreEqual(bytes, copy.ToArray()) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also