CryptoSys API Library Manual

Example: Pbe.Kdf2  (2)

[VB6 equivalent: PBE_Kdf2Hex]

Dim strDerivedKey As String
Dim nKeyLen As Integer
Dim strPassword As String
Dim strSaltHex As String
Dim nCount As Integer

strPassword = "password"  ' NB normal text, not hex

' Set 8-byte salt = 78 57 8E 5A 5D 63 CB 06
strSaltHex = "78578E5A5D63CB06"

' Iteration count is 2048
nCount = 2048

nKeyLen = 24

' Derive PBKDF2 key using function from CryptoSys API
strDerivedKey = Pbe.Kdf2(nKeyLen, strPassword, strSaltHex, nCount)

' Check against test vector
Console.WriteLine("Derived key = " & strDerivedKey)
Console.WriteLine("Correct key = BFDE6BE94DF7E11DD409BCE20A0255EC327CB936FFE93643")

See Also:
Pbe.Kdf2 Method (Int32, String, String, Int32, HashAlgorithm)

[Contents] [Index]

[PREV: Example: Pbe.Kdf2 ...]   [Contents]   [Index]   
   [NEXT: Example: Pc1.Encrypt ...]

Copyright © 2001-23 D.I. Management Services Pty Ltd. All rights reserved. Generated 2023-05-20T13:01:10Z.