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

bytes

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration) 
Public Shared Function FromBytes( _
   ByVal bytes() As Byte _
) As RSAPublicKey
C# 
public static RSAPublicKey FromBytes( 
   byte[] bytes
)

Parameters

bytes

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