CSharpTest.Net
PasswordKey Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PasswordKey Class

Glossary Item Box

Creates an in-memory object that can be used for salted password encryption without storing the password in memory (based on Rfc2898DeriveBytes, SHA1 hash of password is stored)

Object Model

PasswordKey ClassIPasswordDerivedBytes InterfaceSalt Class

Syntax

Visual Basic (Declaration) 
Public Class PasswordKey 
   Inherits CryptoKey
   Implements IEncryptDecrypt 
C# 
public class PasswordKey : CryptoKey, IEncryptDecrypt  

Example

Library/Library.Test/TestPassword.cs

C#Copy Code
byte[] bytes;
byte[] svalue = Encoding.ASCII.GetBytes("some text value");

using (PasswordKey pk = new PasswordKey(TEST_PASSWORD))
    bytes = pk.Encrypt(svalue);

using (PasswordKey pk = new PasswordKey(TEST_PASSWORD))
    bytes = pk.Decrypt(bytes);

Assert.AreEqual(svalue, bytes);
VB.NETCopy Code
Dim bytes As Byte()
Dim svalue As Byte() = Encoding.ASCII.GetBytes("some text value")

Using pk As New PasswordKey(TEST_PASSWORD)
    bytes = pk.Encrypt(svalue)
End Using

Using pk As New PasswordKey(TEST_PASSWORD)
    bytes = pk.Decrypt(bytes)
End Using

Assert.AreEqual(svalue, bytes)

Inheritance Hierarchy

System.Object
   CSharpTest.Net.Crypto.CryptoKey
      CSharpTest.Net.Crypto.PasswordKey
         CSharpTest.Net.Crypto.Password

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys