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

input
inputOffset
output
outputOffset
outputLength

Glossary Item Box

Copies the specified range of characters from the secure string to the output character array.

Syntax

Visual Basic (Declaration) 
Public Shared Sub CopyChars( _
   ByVal input As SecureString, _
   ByVal inputOffset As Integer, _
   ByVal output() As Char, _
   ByVal outputOffset As Integer, _
   ByVal outputLength As Integer _
) 
C# 
public static void CopyChars( 
   SecureString input,
   int inputOffset,
   char[] output,
   int outputOffset,
   int outputLength
)

Parameters

input
inputOffset
output
outputOffset
outputLength

Example

Library/Library.Test/TestSecureString.cs

C#Copy Code
foreach (SecureString ss in MakeStrings())
{
    char[] temp = new char[TEST_PASSWORD.Length];
    SecureStringUtils.CopyChars(ss, 0, temp, 0, temp.Length);
    Assert.AreEqual(TEST_PASSWORD, new String(temp));

    temp = new char[TEST_PASSWORD.Length];
    SecureStringUtils.CopyChars(ss, 4, temp, 4, temp.Length - 4);
    Assert.AreNotEqual(TEST_PASSWORD, new String(temp));
    SecureStringUtils.CopyChars(ss, 0, temp, 0, 4);
    Assert.AreEqual(TEST_PASSWORD, new String(temp));
}
VB.NETCopy Code
For Each ss As SecureString In MakeStrings()
    Dim temp As Char() = New Char(TEST_PASSWORD.Length) {}
    SecureStringUtils.CopyChars(ss, 0, temp, 0, temp.Length)
    Assert.AreEqual(TEST_PASSWORD, New [String](temp))

    temp = New Char(TEST_PASSWORD.Length) {}
    SecureStringUtils.CopyChars(ss, 4, temp, 4, temp.Length - 4)
    Assert.AreNotEqual(TEST_PASSWORD, New [String](temp))
    SecureStringUtils.CopyChars(ss, 0, temp, 0, 4)
    Assert.AreEqual(TEST_PASSWORD, New [String](temp))
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