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

data

Glossary Item Box

Returns a stream of Unicode bytes from the give SecureString instance

Syntax

Visual Basic (Declaration) 
Public Shared Function ToStream( _
   ByVal data As SecureString _
) As Stream
C# 
public static Stream ToStream( 
   SecureString data
)

Parameters

data

Example

Library/Library.Test/TestSecureString.cs

C#Copy Code
byte[] expect = Encoding.Unicode.GetBytes(TEST_PASSWORD);
foreach (SecureString ss in MakeStrings())
{
    Assert.AreEqual(expect, IOStream.ReadAllBytes(SecureStringUtils.ToStream(ss)));
    Assert.AreEqual(TEST_PASSWORD, IOStream.ReadAllText(SecureStringUtils.ToStream(ss), Encoding.Unicode));
}
VB.NETCopy Code
Dim expect As Byte() = Encoding.Unicode.GetBytes(TEST_PASSWORD)
For Each ss As SecureString In MakeStrings()
    Assert.AreEqual(expect, IOStream.ReadAllBytes(SecureStringUtils.ToStream(ss)))
    Assert.AreEqual(TEST_PASSWORD, IOStream.ReadAllText(SecureStringUtils.ToStream(ss), Encoding.Unicode))
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