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

Glossary Item Box

Returns a CspBlob standard binary key definition

Syntax

Visual Basic (Declaration) 
Public Function ToArray() As Byte()
C# 
public byte[] ToArray()

Example

Library/Library.Test/TestRSACrypto.cs

C#Copy Code
RSAPrivateKey pk = new RSAPrivateKey();
string xml = pk.ToXml();

RSAPrivateKey copy = RSAPrivateKey.FromXml(xml);
Assert.AreEqual(xml, copy.ToXml());

byte[] bytes = pk.ToArray();
Assert.AreEqual(596, bytes.Length);

copy = RSAPrivateKey.FromBytes(bytes);
Assert.AreEqual(bytes, copy.ToArray());

copy = RSAPrivateKey.FromParameters(pk.ExportParameters());
Assert.AreEqual(bytes, copy.ToArray());
VB.NETCopy Code
Dim pk As New RSAPrivateKey()
Dim xml As String = pk.ToXml()

Dim copy As RSAPrivateKey = RSAPrivateKey.FromXml(xml)
Assert.AreEqual(xml, copy.ToXml())

Dim bytes As Byte() = pk.ToArray()
Assert.AreEqual(596, bytes.Length)

copy = RSAPrivateKey.FromBytes(bytes)
Assert.AreEqual(bytes, copy.ToArray())

copy = RSAPrivateKey.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