CSharpTest.Net
FromXml(String) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > FromXml Method : FromXml(String) Method

xml

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function FromXml( _
   ByVal xml As String _
) As RSAPublicKey
C# 
public static RSAPublicKey FromXml( 
   string xml
)

Parameters

xml

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.NETCopy 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

Generated with Document! X 2011 by Innovasys