CSharpTest.Net
ToByteArray(SecureString) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class > ToByteArray Method : ToByteArray(SecureString) Method

data

Glossary Item Box

Converts a System.Security.SecureString into an array of bytes using System.Text.Encoding.Unicode

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function ToByteArray( _
   ByVal data As SecureString _
) As Byte()
C# 
public static byte[] ToByteArray( 
   SecureString data
)

Parameters

data

Example

Library/Library.Test/TestSecureString.cs

C#Copy Code
foreach (SecureString ss in MakeStrings())
{
    Assert.AreEqual(Encoding.Unicode.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss));
    Assert.AreEqual(Encoding.UTF8.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss, Encoding.UTF8));
}
VB.NETCopy Code
For Each ss As SecureString In MakeStrings()
    Assert.AreEqual(Encoding.Unicode.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss))
    Assert.AreEqual(Encoding.UTF8.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss, Encoding.UTF8))
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys