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
CryptGenKey
CryptGenRandom
CryptGetDefaultProvider
CryptGetHashParam
CryptGetKeyParam
CryptGetProvParam
CryptHashData
CryptProtectData
CryptReleaseContext
CryptStringToBinary
CryptUnprotectData
WinVerifyTrust
Code examples:
A class that encrypts and decrypts files using Cryptography API Functions
CryptoAPI: Collection of Providers class
How to create MD-5 and SHA-1 hash values from a string
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: 28  
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-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (72.44.48.122)
3 sec.Function: 'WaitForSingleObject'
6 sec.Example: 'How to delete all print jobs for a printer'
56.37 min.Example: 'Enumerating print jobs and retrieving information for default printer (JOB_INFO_1 structures)'
56.43 min.Function: 'LsaLookupSids'
Function group: 'Security'
56.48 min.Function: 'WTSUnRegisterSessionNotification'
1.9 hrs.Function: 'DrawAnimatedRects'
Function group: 'Painting and Drawing'
1.91 hrs.Example: 'Displaying printer-properties Property Sheet for the specified printer'
2.64 hrs.Example: 'Tracking mouse movement to detect when to start dragging'
4.49 hrs.Function: 'RegisterHotKey'
Function group: 'Keyboard Input'
 Function: 'DrawDibOpen'
Function group: 'Windows Multimedia'
Google
Advertise here!