Using Win32 functions in Visual FoxPro Image Gallery
Cryptography Reference
..msdn
CertCloseStore
CertFindCertificateInStore
CertFreeCertificateContext
CertOpenSystemStore
CryptAcquireContext
CryptBinaryToString
CryptCreateHash
CryptDecrypt
CryptDeriveKey
CryptDestroyHash
CryptDestroyKey
CryptEncrypt
CryptEnumProviders
CryptEnumProviderTypes
CryptExportKey
CryptGenKey
CryptGenRandom
CryptGetDefaultProvider
CryptGetHashParam
CryptGetKeyParam
CryptGetProvParam
CryptHashData
CryptImportKey
CryptProtectData
CryptReleaseContext
CryptStringToBinary
CryptUnprotectData
WinVerifyTrust
Code examples:
How to fill a buffer with random bytes using Cryptography API Functions
How to fill a buffer with random bytes using Cryptography API Functions

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
Use this code to fill a large buffer (a string) with random characters. MS even insists that these characters would be far more random than any created by standard random function.
#DEFINE PROV_RSA_FULL 1
#DEFINE CRYPT_VERIFYCONTEXT 0xf0000000
DO declare

LOCAL hProvider, cBuffer
hProvider=0

* obtain CSP handle
IF CryptAcquireContext(@hProvider, NULL, NULL,;
    PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) = 0
    ? "Call to CryptAcquireContext failed:", GetLastError()
    RETURN
ENDIF

* allocate buffer that will receive random data
cBuffer = REPLICATE(CHR(0), 1024)

* fill the buffer with cryptographically random bytes
IF CryptGenRandom(m.hProvider, LEN(m.cBuffer), @cBuffer) = 0
    ? "Call to CryptGenRandom failed:", GetLastError()
ELSE
    CREATE CURSOR cs (randbytes M)
    INSERT INTO cs VALUES (m.cBuffer)
    MODIFY MEMO randbytes NOWAIT
ENDIF

= CryptReleaseContext(m.hProvider, 0)
* end of main

PROCEDURE declare
    DECLARE INTEGER GetLastError IN kernel32

    DECLARE INTEGER CryptGenRandom IN advapi32;
        INTEGER hProv, LONG dwLen, STRING @pbBuffer

    DECLARE INTEGER CryptAcquireContext IN advapi32;
        INTEGER @hProvHandle, STRING cContainer, ;
        STRING cProvider, INTEGER nProvType, INTEGER nFlags

    DECLARE INTEGER CryptReleaseContext IN advapi32;
        INTEGER hProvHandle, INTEGER nReserved

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1139 bytes  
Created: 2001-07-19 12:00:00  
Modified: 2010-08-05 10:00:28  
Visits in 7 days: 58  
Listed functions:
CryptAcquireContext
CryptGenRandom
CryptReleaseContext
GetLastError
Printer friendly API declarations
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright 2001-2018 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.226.55.151)
11 sec.Function: 'CeCreateProcess'
Function group: 'Remote Application Programming (RAPI)'
25 sec.Function: 'SHBrowseForFolder'
Function group: 'Shell Functions'
37 sec.Function: 'SetMailslotInfo'
48 sec.Example: 'Obtaining names of local and global groups for current user (WinNT/XP/2K)'
1.02 min.Function: 'CeGetSpecialFolderPath'
Function group: 'Remote Application Programming (RAPI)'
1.23 min.Example: 'GDI+: Drawing a Pie Chart'
1.47 min.Function: 'SHCreateDirectory'
Function group: 'Shell Functions'
1.92 min.Function: 'mixerClose'
Function group: 'Windows Multimedia'
2.13 min.Function: 'GetFileNameFromBrowse'
Function group: 'Shell Functions'
2.37 min.Example: 'System Image List Viewer'
Google
Advertise here!