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() |
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.NET | Copy 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