本文整理汇总了C++中CryptEncrypt函数的典型用法代码示例。如果您正苦于以下问题:C++ CryptEncrypt函数的具体用法?C++ CryptEncrypt怎么用?C++ CryptEncrypt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CryptEncrypt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exsltCryptoCryptoApiRc4Encrypt
void
exsltCryptoCryptoApiRc4Encrypt (xmlXPathParserContextPtr ctxt,
const unsigned char *key,
const unsigned char *msg, int msglen,
unsigned char *dest, int destlen) {
HCRYPTPROV hCryptProv;
HCRYPTKEY hKey;
HCRYPTHASH hHash;
DWORD dwDataLen;
unsigned char hash[HASH_DIGEST_LENGTH];
if (msglen > destlen) {
xsltTransformError (xsltXPathGetTransformContext (ctxt), NULL,
NULL,
"exslt:crypto : internal error exsltCryptoCryptoApiRc4Encrypt dest buffer too small.\n");
return;
}
if (!CryptAcquireContext (&hCryptProv, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
exsltCryptoCryptoApiReportError (ctxt, __LINE__);
return;
}
hHash = exsltCryptoCryptoApiCreateHash (ctxt, hCryptProv,
CALG_SHA1, key,
RC4_KEY_LENGTH, hash,
HASH_DIGEST_LENGTH);
if (!CryptDeriveKey
(hCryptProv, CALG_RC4, hHash, 0x00800000, &hKey)) {
exsltCryptoCryptoApiReportError (ctxt, __LINE__);
goto fail;
}
/* Now encrypt data. */
dwDataLen = msglen;
memcpy (dest, msg, msglen);
if (!CryptEncrypt (hKey, 0, TRUE, 0, dest, &dwDataLen, msglen)) {
exsltCryptoCryptoApiReportError (ctxt, __LINE__);
goto fail;
}
fail:
if (0 != hHash) {
CryptDestroyHash (hHash);
}
CryptDestroyKey (hKey);
CryptReleaseContext (hCryptProv, 0);
}
示例2: crypto_cipher_encrypt
int crypto_cipher_encrypt(struct crypto_cipher *ctx, const u8 *plain,
u8 *crypt, size_t len)
{
DWORD dlen;
os_memcpy(crypt, plain, len);
dlen = len;
if (!CryptEncrypt(ctx->key, 0, FALSE, 0, crypt, &dlen, len)) {
cryptoapi_report_error("CryptEncrypt");
os_memset(crypt, 0, len);
return -1;
}
return 0;
}
示例3: CreateCryptBlock
// Create or update a cryptographic context for a pager.
// This function will automatically determine if the encryption algorithm requires
// extra padding, and if it does, will create a temp buffer big enough to provide
// space to hold it.
static LPCRYPTBLOCK CreateCryptBlock(HCRYPTKEY hKey, Pager *pager, int pageSize, LPCRYPTBLOCK pExisting)
{
LPCRYPTBLOCK pBlock;
if (!pExisting) // Creating a new cryptblock
{
pBlock = sqlite3_malloc(sizeof(CRYPTBLOCK));
if (!pBlock) return NULL;
ZeroMemory(pBlock, sizeof(CRYPTBLOCK));
pBlock->hReadKey = hKey;
pBlock->hWriteKey = hKey;
}
else // Updating an existing cryptblock
{
pBlock = pExisting;
}
if (pageSize == -1)
pageSize = pager->pageSize;
pBlock->pPager = pager;
pBlock->dwPageSize = (DWORD)pageSize;
pBlock->dwCryptSize = pBlock->dwPageSize;
// Existing cryptblocks may have a buffer, if so, delete it
if (pBlock->pvCrypt)
{
sqlite3_free(pBlock->pvCrypt);
pBlock->pvCrypt = NULL;
}
// Figure out how big to make our spare crypt block
CryptEncrypt(hKey, 0, TRUE, 0, NULL, &pBlock->dwCryptSize, pBlock->dwCryptSize * 2);
pBlock->pvCrypt = sqlite3_malloc(pBlock->dwCryptSize + (CRYPT_OFFSET * 2));
if (!pBlock->pvCrypt)
{
// We created a new block in here, so free it. Otherwise leave the original intact
if (pBlock != pExisting)
sqlite3_free(pBlock);
return NULL;
}
return pBlock;
}
示例4: create_des_key
static HCRYPTKEY create_des_key(unsigned char *key) {
HCRYPTKEY hSessionKey, hPrivateKey;
DWORD dlen = 8;
BLOBHEADER *pbh;
char buf[sizeof(BLOBHEADER) + sizeof(ALG_ID) + 256];
/*
* Need special private key to encrypt session key so we can
* import session key, since only encrypted session keys can be
* imported
*/
if(CryptImportKey(hCryptProv, PrivateKeyWithExponentOfOne,
sizeof(PrivateKeyWithExponentOfOne),
0, 0, &hPrivateKey) == 0)
return 0;
/* now encrypt session key using special private key */
memcpy(buf + sizeof(BLOBHEADER) + sizeof(ALG_ID), key, 8);
if(CryptEncrypt(hPrivateKey, 0, TRUE, 0,
buf + sizeof(BLOBHEADER) + sizeof(ALG_ID),
&dlen, 256) == 0)
return 0;
/* build session key blob */
pbh = (BLOBHEADER*)buf;
pbh->bType = SIMPLEBLOB;
pbh->bVersion = 0x02;
pbh->reserved = 0;
pbh->aiKeyAlg = CALG_DES;
*((ALG_ID*)(buf+sizeof(BLOBHEADER))) = CALG_RSA_KEYX;
/* import session key into key container */
if(CryptImportKey(hCryptProv, buf,
dlen + sizeof(BLOBHEADER) + sizeof(ALG_ID),
hPrivateKey, 0, &hSessionKey) == 0)
return 0;
if(hPrivateKey)
CryptDestroyKey(hPrivateKey);
return hSessionKey;
}
示例5: DWORD
std::string CStringUtils::Encrypt(const std::string& s, const std::string& password)
{
std::string encryptedstring;
HCRYPTPROV hProv = NULL;
// Get handle to user default provider.
if (CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
{
HCRYPTHASH hHash = NULL;
// Create hash object.
if (CryptCreateHash(hProv, CALG_SHA_512, 0, 0, &hHash))
{
// Hash password string.
DWORD dwLength = DWORD(sizeof(WCHAR)*password.size());
if (CryptHashData(hHash, (BYTE *)password.c_str(), dwLength, 0))
{
// Create block cipher session key based on hash of the password.
HCRYPTKEY hKey = NULL;
if (CryptDeriveKey(hProv, CALG_AES_256, hHash, CRYPT_EXPORTABLE, &hKey))
{
// Determine number of bytes to encrypt at a time.
std::string starname = "*";
starname += s;
dwLength = (DWORD)starname.size();
std::unique_ptr<BYTE[]> buffer(new BYTE[dwLength + 1024]);
memcpy(buffer.get(), starname.c_str(), dwLength);
// Encrypt data
if (CryptEncrypt(hKey, 0, true, 0, buffer.get(), &dwLength, dwLength + 1024))
{
encryptedstring = CStringUtils::ToHexString(buffer.get(), dwLength);
}
CryptDestroyKey(hKey); // Release provider handle.
}
}
CryptDestroyHash(hHash);
}
CryptReleaseContext(hProv, 0);
}
else
DebugBreak();
return encryptedstring;
}
示例6: CryptEncrypt
bool Crypt::Encrypt( PBYTE data, DWORD length )
{
// Encrypt the data.
DWORD dwLength = length;
BOOL fReturn = CryptEncrypt(
m_SessionKeyEn,
0,
TRUE,
0,
data,
&length,
length );
if ( !fReturn )
{
printf( "Encrypt error : %d\n", GetLastError() );
ReleaseResources();
return false;
}
return true;
}
示例7: memset
CString Crytography ::Encrypt(CString mes)
{
CString m_cipher;
unsigned long length = mes.GetLength() +1;
unsigned char * cipherBlock = (unsigned char*)malloc(length);
memset(cipherBlock, 0, length);
memcpy(cipherBlock, mes, length -1);
if (!CryptEncrypt(hKey, 0, TRUE, 0, cipherBlock, &length, length))
{
//dwResult = GetLastError();
AfxMessageBox("Error CryptEncrypt() failed.", MB_OK);
return "";
}
m_cipher = cipherBlock;
//m_clear = "";
free(cipherBlock);
//
return m_cipher;
}
示例8: RSA_encrypt
/**
* Encrypts a small block of data with an RSA public key.
* Output buffer must be at least the key size.
*/
int RSA_encrypt(RSA_key_t rsa, const unsigned char *from, int fromlen,
unsigned char *to, int *tolen)
{
DWORD _tolen;
int flags;
unsigned int i;
unsigned char *outbuf;
if (RSA_keylen(rsa) * 8 < 768) {
flags = 0;
} else {
flags = CRYPT_OAEP;
}
outbuf = calloc(RSA_keylen(rsa), 1);
if (outbuf == NULL) {
syserror(0, 0, "calloc failed!");
exit(1);
}
memcpy(outbuf, from, fromlen);
_tolen = fromlen;
if (!CryptEncrypt(rsa, 0, 1, flags, outbuf, &_tolen, RSA_keylen(rsa))) {
mserror("CryptEncrypt failed");
free(outbuf);
return 0;
}
*tolen = _tolen;
// CryptoAPI returns ciphertext in little endian, so reverse the bytes
for (i = 0; i < _tolen; i++) {
to[i] = outbuf[_tolen - i - 1];
}
free(outbuf);
return 1;
}
示例9: good1
/* good1() uses the GoodSinkBody in the for statements */
static void good1()
{
int k;
for(k = 0; k < 1; k++)
{
{
BYTE payload[100];
DWORD payloadLen = strlen(PAYLOAD);
HCRYPTPROV hCryptProv = (HCRYPTPROV)NULL;
HCRYPTHASH hHash = (HCRYPTHASH)NULL;
HCRYPTKEY hKey = (HCRYPTKEY)NULL;
char hashData[100] = HASH_INPUT;
do
{
/* Copy plaintext into payload buffer */
memcpy(payload, PAYLOAD, payloadLen);
/* Aquire a Context */
if(!CryptAcquireContext(&hCryptProv, NULL, MS_ENH_RSA_AES_PROV, PROV_RSA_AES, 0))
{
break;
}
/* Create hash handle */
if(!CryptCreateHash(hCryptProv, CALG_SHA_256, 0, 0, &hHash))
{
break;
}
/* FIX: All required steps are present */
/* Hash the input string */
if(!CryptHashData(hHash, (BYTE*)hashData, strlen(hashData), 0))
{
break;
}
/* Derive an AES key from the hash */
if(!CryptDeriveKey(hCryptProv, CALG_AES_256, hHash, 0, &hKey))
{
break;
}
/* Encrypt the payload */
if(!CryptEncrypt(hKey, 0, 1, 0, payload, &payloadLen, sizeof(payload)))
{
break;
}
}
while (0);
if (hKey)
{
CryptDestroyKey(hKey);
}
if (hHash)
{
CryptDestroyHash(hHash);
}
if (hCryptProv)
{
CryptReleaseContext(hCryptProv, 0);
}
/* Do something with the encrypted data */
printBytesLine(payload, payloadLen);
}
}
}
开发者ID:gpwi970725,项目名称:testJuliet2,代码行数:62,代码来源:CWE325_Missing_Required_Cryptographic_Step__w32_CryptHashData_17.c
示例10: WriteDebugInfo
//.........这里部分代码省略.........
for(i=0;i<dwCount;i++) printf("%2.2x ",pbData[i]);
printf("\n");
// Read the initialization vector.
dwCount = 16;
if(!CryptGetKeyParam(hKey, KP_IV, pbData, &dwCount, 0)) {
printf("Error %x during CryptGetKeyParam!\n", GetLastError());
return 1;
}
// Print out the initialization vector.
printf("Default IV:");
for(i=0;i<dwCount;i++) printf("%2.2x ",pbData[i]);
printf("\n");
// Set the cipher mode.
dwMode = CRYPT_MODE_OFB;
if(!CryptSetKeyParam(hKey, KP_MODE, (BYTE *)&dwMode, 0)) {
printf("Error %x during CryptSetKeyParam!\n", GetLastError());
return 1;
}
// Read the cipher mode.
dwCount = sizeof(DWORD);
if(!CryptGetKeyParam(hKey, KP_MODE, (BYTE *)&dwMode, &dwCount, 0)) {
printf("Error %x during CryptGetKeyParam!\n", GetLastError());
return 1;
}
// Print out the cipher mode.
printf("Default cipher mode: %d\n", dwMode);
dwCount = 16;
BYTE pbIV[17];
CryptGenRandom(hProvider, dwCount, pbIV);
if(!CryptSetKeyParam(hKey, KP_IV, pbIV, 0)) {
printf("Error %x during CryptGetKeyParam!\n", GetLastError());
return 1;
}
// Read the initialization vector.
dwCount = 16;
if(!CryptGetKeyParam(hKey, KP_IV, pbData, &dwCount, 0)) {
printf("Error %x during CryptGetKeyParam!\n", GetLastError());
return 1;
}
// Print out the initialization vector.
printf("Default IV:");
for(i=0;i<dwCount;i++) printf("%2.2x ",pbData[i]);
printf("\n");
if(!CryptSetKeyParam(hKey, KP_SALT, pbIV, 0)) {
printf("Error %x during CryptGetKeyParam!\n", GetLastError());
return 1;
}
// Read the salt.
dwCount = 16;
if(!CryptGetKeyParam(hKey, KP_SALT, pbData, &dwCount, 0)) {
printf("Error %x during CryptGetKeyParam!\n", GetLastError());
return 1;
}
// Print out the initialization vector.
printf("Default IV:");
for(i=0;i<dwCount;i++) printf("%2.2x ",pbData[i]);
printf("\n");
////////////////////////////////////////////
strcpy((char *)pbBuffer, test);
DebugLog((DEST,"%s",(char *)pbBuffer));
dwByteCount = strlen((char *)pbBuffer);
rc = CryptEncrypt(hKey, 0, finished, 0, pbBuffer, &dwByteCount, OUT_BUFFER_SIZE);
DebugLog((DEST,"Encrypted buffer"));
rc = CryptDecrypt(hKey, 0, finished, 0, pbBuffer, &dwByteCount);
DebugLog((DEST,"Decrypted buffer"));
DebugLog((DEST,"%s",(char *)pbBuffer));
if (strcmp((char *)pbBuffer,test) ==0)
{
DebugLog((DEST,"Encrypt/Decrypt Succeeded"));
}
else
{
DebugLog((DEST,"Encrypt/Decrypt Failed"));
}
CleanupCryptoKey(hExchangeKey);
CleanupCryptoKey(hKey);
CleanupCryptoContext(hProvider);
DebugLog((DEST,"Listing Providers."));
ListProviders();
return(0);
}
示例11: Encrypt
int Encrypt(char * inFile, char * outFile, char * keyFile) {
const IN_BUFFER_SIZE = 2048;
const OUT_BUFFER_SIZE = IN_BUFFER_SIZE + 64; // extra padding
HANDLE hInFile;
HANDLE hOutFile;
HANDLE hKeyFile;
BYTE pbBuffer[OUT_BUFFER_SIZE];
BOOL finished;
HCRYPTPROV hProvider = 0;
HCRYPTKEY hKey = 0, hExchangeKey = 0;
DWORD dwByteCount, dwBytesWritten;
long rc=0;
// Open infile and create outfile.
hInFile = CreateFile(inFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
hOutFile = CreateFile(outFile, GENERIC_WRITE, FILE_SHARE_READ,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
DebugLog((DEST,"PrepContext"));
PrepContext(iWinVer, &hProvider);
hKeyFile = CreateFile(keyFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
DebugLog((DEST,"ImportCryptKey"));
ImportCryptKey(hProvider, &hKey, hKeyFile);
DWORD dwCount = 11;
BYTE pbIV[11];
//CryptGenRandom(hProvider, dwCount, pbIV);
strcpy((char *)pbIV,"12345678901");
if(!CryptSetKeyParam(hKey, KP_SALT, pbIV, 0)) {
printf("Error %x during CryptGetKeyParam!\n", GetLastError());
return 1;
}
// Now, read data in, encrypt it, and write encrypted data to output.
do
{
ReadFile(hInFile, pbBuffer, IN_BUFFER_SIZE,&dwByteCount,NULL);
finished = (dwByteCount < IN_BUFFER_SIZE);
rc = CryptEncrypt(hKey, 0, finished, 0, pbBuffer, &dwByteCount,
OUT_BUFFER_SIZE);
PrintLog((DEST,"Finished = %d ",finished));
WriteFile(hOutFile, pbBuffer, dwByteCount, &dwBytesWritten,
NULL);
} while (!finished);
//And we’re finished
//almost. All we need to do now is clean up. We’re finished with both keys at this point, so let’s delete them.
// Clean up: release handles, close files.
CleanupCryptoKey(hExchangeKey);
CleanupCryptoKey(hKey);
//We’re finished using the CSP handle, so we must release it. We close the input and output files, and we’re finished.
CleanupCryptoContext(hProvider);
CloseHandle(hInFile);
CloseHandle(hOutFile);
return (0);
}
示例12: CWE321_Hard_Coded_Cryptographic_Key__w32_char_64b_goodG2BSink
/* goodG2B uses the GoodSource with the BadSink */
void CWE321_Hard_Coded_Cryptographic_Key__w32_char_64b_goodG2BSink(void * cryptoKeyVoidPtr)
{
/* cast void pointer to a pointer of the appropriate type */
char * * cryptoKeyPtr = (char * *)cryptoKeyVoidPtr;
/* dereference cryptoKeyPtr into cryptoKey */
char * cryptoKey = (*cryptoKeyPtr);
{
HCRYPTPROV hCryptProv;
HCRYPTKEY hKey;
HCRYPTHASH hHash;
char toBeEncrypted[] = "String to be encrypted";
DWORD encryptedLen = strlen(toBeEncrypted)*sizeof(char);
BYTE encrypted[200]; /* buffer should be larger than toBeEncrypted to have room for IV and padding */
/* Copy plaintext (without NUL terminator) into byte buffer */
memcpy(encrypted, toBeEncrypted, encryptedLen);
/* Try to get a context with and without a new key set */
if(!CryptAcquireContext(&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_AES, 0))
{
if(!CryptAcquireContext(&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_AES, CRYPT_NEWKEYSET))
{
printLine("Error in acquiring cryptographic context");
exit(1);
}
}
/* Create Hash handle */
if(!CryptCreateHash(hCryptProv, CALG_SHA_256, 0, 0, &hHash))
{
printLine("Error in creating hash");
exit(1);
}
/* Hash the cryptoKey */
if(!CryptHashData(hHash, (BYTE *) cryptoKey, strlen(cryptoKey)*sizeof(char), 0))
{
printLine("Error in hashing cryptoKey");
exit(1);
}
/* Derive an AES key from the Hashed cryptoKey */
if(!CryptDeriveKey(hCryptProv, CALG_AES_256, hHash, 0, &hKey))
{
printLine("Error in CryptDeriveKey");
exit(1);
}
/* POTENTIAL FLAW: Possibly using a hardcoded crypto key */
/* Use the derived key to encrypt something */
if(!CryptEncrypt(hKey, (HCRYPTHASH)NULL, 1, 0, encrypted, &encryptedLen, sizeof(encrypted)))
{
printLine("Error in CryptEncrypt");
exit(1);
}
/* use encrypted block */
printBytesLine(encrypted, encryptedLen);
if (hKey)
{
CryptDestroyKey(hKey);
}
if (hHash)
{
CryptDestroyHash(hHash);
}
if (hCryptProv)
{
CryptReleaseContext(hCryptProv, 0);
}
}
}
示例13: rsaencrypt
void rsaencrypt(unsigned char *data, int length, struct RSAKey *rsakey) {
int i;
unsigned char *pKeybuf, *pKeyin;
HCRYPTKEY hRsaKey;
PUBLICKEYSTRUC *pBlob;
RSAPUBKEY *pRPK;
unsigned char *buf;
DWORD dlen;
DWORD bufsize;
/* allocate buffer for public key blob */
if((pBlob = malloc(sizeof(PUBLICKEYSTRUC) + sizeof(RSAPUBKEY) +
rsakey->bytes)) == NULL)
fatalbox("Out of memory");
/* allocate buffer for message encryption block */
bufsize = (length + rsakey->bytes) << 1;
if((buf = malloc(bufsize)) == NULL)
fatalbox("Out of memory");
/* construct public key blob from host public key */
pKeybuf = ((unsigned char*)pBlob) + sizeof(PUBLICKEYSTRUC) +
sizeof(RSAPUBKEY);
pKeyin = ((unsigned char*)rsakey->modulus);
/* change big endian to little endian */
for(i=0; i<rsakey->bytes; i++)
pKeybuf[i] = pKeyin[rsakey->bytes-i-1];
pBlob->bType = PUBLICKEYBLOB;
pBlob->bVersion = 0x02;
pBlob->reserved = 0;
pBlob->aiKeyAlg = CALG_RSA_KEYX;
pRPK = (RSAPUBKEY*)(((unsigned char*)pBlob) + sizeof(PUBLICKEYSTRUC));
pRPK->magic = 0x31415352; /* "RSA1" */
pRPK->bitlen = rsakey->bits;
pRPK->pubexp = rsakey->exponent;
/* import public key blob into key container */
if(CryptImportKey(hCryptProv, (void*)pBlob,
sizeof(PUBLICKEYSTRUC)+sizeof(RSAPUBKEY)+rsakey->bytes,
0, 0, &hRsaKey) == 0)
fatalbox("Error importing RSA key!");
/* copy message into buffer */
memcpy(buf, data, length);
dlen = length;
/* using host public key, encrypt the message */
if(CryptEncrypt(hRsaKey, 0, TRUE, 0, buf, &dlen, bufsize) == 0)
fatalbox("Error encrypting using RSA key!");
/*
* For some strange reason, Microsoft CryptEncrypt using public
* key, returns the cyphertext in backwards (little endian)
* order, so reverse it!
*/
for(i = 0; i < (int)dlen; i++)
data[i] = buf[dlen - i - 1]; /* make it big endian */
CryptDestroyKey(hRsaKey);
free(buf);
free(pBlob);
}
示例14: MyHandleError
//.........这里部分代码省略.........
} else {
ltemp = 0;
fread (<emp, 1, sizeof (unsigned long), hSource);
fread (<emp, 1, sizeof (unsigned long), hSource);
fread (<emp, 1, sizeof (unsigned long), hSource);
fread (<emp, 1, sizeof (unsigned long), hSource);
}
//-------------------------------------------------------------------
// In a do loop, encrypt the source file,
// and write to the source file.
m_lastprogressvalue = 0;
m_bmaxprogressredone = false;
m_ispeedtrigger = 0;
unsigned long ltimereading = 0;
unsigned long long lbytesreading = 0;
int ispeed = 0;
int iaverage = 0;
m_lastbytesreading = 0;
m_lasttimereading = 0;
do
{
//-------------------------------------------------------------------
// Read up to dwBlockLen bytes from the source file.
dwCount = fread(pbBuffer, 1, dwBlockLen, hSource);
if(ferror(hSource)) {
MyHandleError("Error reading plaintext!");
return false;
}
//-------------------------------------------------------------------
// Encrypt / Decrypt data.
if (bEncrypt == true) {
if(!CryptEncrypt(hKey, 0, feof(hSource), 0, pbBuffer, &dwCount, dwBufferLen)) {
MyHandleError("Error during Encrypt.");
return false;
}
} else {
if(!CryptDecrypt(hKey, 0, feof(hSource), 0, pbBuffer, &dwCount)) {
MyHandleError("Error during Decrypt.");
return false;
}
}
//-------------------------------------------------------------------
// Write data to the destination file.
fwrite(pbBuffer, 1, dwCount, hDestination);
ltotalbytesprocessed+=dwCount;
//OutputInt ("ltotalprocessed: ", ltotalbytesprocessed);
int idivvalue = 1000;
if (ltotalbytes > 0 && ltotalbytes <= 1000) {
idivvalue = 1;
}
if (ltotalbytes > 1000 && ltotalbytes <= 10000) {
idivvalue = 10;
}
if (ltotalbytes > 10000 && ltotalbytes <= 100000) {
idivvalue = 100;
}
if (ltotalbytes > 100000 && ltotalbytes <= 1000000) {
idivvalue = 1000;
示例15: des_encrypt_blk
void des_encrypt_blk(unsigned char *blk, int len) {
DWORD dlen;
dlen = len;
if(CryptEncrypt(hDESKey[0][0], 0, FALSE, 0, blk, &dlen, len + 8) == 0)
fatalbox("Error encrypting block!\n");
}