
SDK
Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0, Windows Me, Windows 98, Windows 95 OSR2 and later.
In post #3 above replace the Code section headed 'Global GetCrypto As ICryptoRand' with the following - everthing else holds.
Code:
Global GetCrypto As ICryptoRand Declare Function CryptAcquireContext Lib "advapi32.dll" Alias "CryptAcquireContextA" _ ( hProv As Long, zContainer As Asciiz, zProvider As Asciiz, _ ByVal dwProvType As Dword, ByVal dwFlags As Dword ) As Long Declare Function CryptReleaseContext Lib "advapi32.dll" Alias "CryptReleaseContext" _ ( ByVal hProv As Long, ByVal dwFlags As Dword ) As Long Declare Function CryptGenRandom Lib "advapi32.dll" Alias "CryptGenRandom" _ ( ByVal hProv As Long, ByVal dwLen As Dword, pbBuffer As Byte) As Long Type mwcParams Mult As Word Random As Long Carry As Long End Type Union CryptoBuffer sDummy As String * 10 mwc As mwcParams End Union Class CCryptoRand Instance hProv As Dword Class Method Create Local Prov_Rsa_Full, Flags As Dword Dim MS_Def_Prov As Asciiz * 50 Prov_Rsa_Full = 1 Flags = &hF0000000 MS_Def_Prov = "Microsoft Base Cryptographic Provider v1.0" CryptAcquireContext( hProv, ByVal %Null, ByVal %Null, Prov_Rsa_Full, Flags ) CryptAcquireContext( hProv, ByVal %Null, MS_Def_Prov, Prov_Rsa_Full, Flags ) End Method Class Method Destroy CryptReleaseContext hProv, 0 End Method Interface ICryptoRand: Inherit IUnknown Method Bytes( x As CryptoBuffer) As Long Dim BinaryByte(10) As Byte Local BinarySize As Dword BinarySize = 10 CryptGenRandom( ByVal hProv, ByVal BinarySize, BinaryByte(0)) x.sDummy = Peek$( VarPtr( BinaryByte(0) ), BinarySize ) End Method End Interface End Class
Leave a comment: