Quelqu'un aurait-il des informations sur la Windows Crypt=20
API (CAPI) pour crypter/d=E9crypter des informations dans=20
une application ? Est-elle disponible avec Windows 2000,=20
et comment l'utiliser ?
D'avance merci pour votre aide.
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Jean-Claude BELLAMY
proc s'est ainsi exprimé:
Quelqu'un aurait-il des informations sur la Windows Crypt API (CAPI) pour crypter/décrypter des informations dans une application ? Est-elle disponible avec Windows 2000,
Oui, toutes les fonctions de chiffrement sont disponibles, et utilisables dans n'importe quelle appli (en VB, en C++, en Delphi,..) (je suis en train d'en écrire une en Delphi)
et comment l'utiliser ? Cela dépend du langage.
Sous Visual Studio (6 et .NET), c'est prévu d'origine (include "wincrypt.h", library "crypt32.lib") Sous Delphi, (V6 et antérieures), on peut trouver l'unité "qui va bien" chez un russe : http://codecentral.borland.com/codecentral/ccweb.exe/listing?id597
Il existe un grand nombre de fonctions
Les 2 plus "classiques" sont CryptProtectData CryptUnProtectData
(mais il doit exister pas loin d'une centaines de fonctions, de chiffrement, hachage, certification, vérification de signature, ...)
En Delphi : ---------- function CryptProtectData( pDataIn: PDATA_BLOB; //données à chiffer szDataDescr: LPCWSTR; /description des données (optionnel) pOptionalEntropy: PDATA_BLOB; //mot de passe supplémentaire ou netropei de chiffremnt (optionnel) pvReserved: pointer; pPromptStruct: PCRYPTPROTECT_PROMPTSTRUCT; //paramètres de la boite de dialogue apparaissant (optionnel) dwFlags: DWORD; //paramètres de chiffrement (chiffrement lié à la machine plutôt que l'utilisateur, audit, vérification ... var pDataOut: DATA_BLOB // données chiffrées ): BOOL; stdcall;
function CryptUnprotectData( pDataIn: PDATA_BLOB; // in encr blob var ppszDataDescr: LPWSTR; // out pOptionalEntropy: PDATA_BLOB; pvReserved: pointer; pPromptStruct: PCRYPTPROTECT_PROMPTSTRUCT; dwFlags: DWORD; var pDataOut: DATA_BLOB ): BOOL; stdcall;
ZeroMemory(&PromptStruct, sizeof(PromptStruct)); PromptStruct.cbSize = sizeof(PromptStruct); PromptStruct.dwPromptFlags = CRYPTPROTECT_PROMPT_ON_PROTECT; PromptStruct.szPrompt = L"This is a user prompt.";
//-------------------------------------------------------------------- // Begin protect phase.
if(CryptProtectData( &DataIn, L"This is the description string.", // A description string. NULL, // Optional entropy not used. NULL, // Reserved. &PromptStruct, // Pass a PromptStruct. 0, &DataOut)) { printf("The encryption phase worked. n"); } else { MyHandleError("Encryption error!"); } //----------------------------------------------------------------- // Begin unprotect phase.
if (CryptUnprotectData( &DataOut, &pDescrOut, NULL, // Optional entropy NULL, // Reserved &PromptStruct, // Optional PromptStruct 0, &DataVerify)) { printf("The decrypted data is: %sn", DataVerify.pbData); printf("The description of the data was: %Sn",pDescrOut); } else { MyHandleError("Decryption error!"); } //------------------------------------------------------------------- // At this point, memcmp could be used to compare DataIn.pbData and // DataVerify.pbDate for equality. If the two functions worked // correctly, the two byte strings are identical.
LocalFree(pDescrOut); LocalFree(DataOut.pbData); LocalFree(DataVerify.pbData); } // End of main
//-------------------------------------------------------------------- // This example uses the function MyHandleError, a simple error // handling function, to print an error message to the standard error // (stderr) file and exit the program. // For most applications, replace this function with one // that does more extensive error reporting.
void MyHandleError(char *s) { fprintf(stderr,"An error occurred in running the program. n"); fprintf(stderr,"%sn",s); fprintf(stderr, "Error number %x.n", GetLastError()); fprintf(stderr, "Program terminating. n"); exit(1); } // End of MyHandleError -- May the Force be with You! La Connaissance s'accroît quand on la partage ---------------------------------------------------------- Jean-Claude BELLAMY [MVP] - http://www.bellamyjc.org *
proc <projets@projipe.fr> s'est ainsi exprimé:
Quelqu'un aurait-il des informations sur la Windows Crypt
API (CAPI) pour crypter/décrypter des informations dans
une application ?
Est-elle disponible avec Windows 2000,
Oui, toutes les fonctions de chiffrement sont disponibles, et utilisables
dans n'importe quelle appli (en VB, en C++, en Delphi,..)
(je suis en train d'en écrire une en Delphi)
et comment l'utiliser ?
Cela dépend du langage.
Sous Visual Studio (6 et .NET), c'est prévu d'origine (include "wincrypt.h",
library "crypt32.lib")
Sous Delphi, (V6 et antérieures), on peut trouver l'unité "qui va bien" chez
un russe :
http://codecentral.borland.com/codecentral/ccweb.exe/listing?id597
Il existe un grand nombre de fonctions
Les 2 plus "classiques" sont
CryptProtectData
CryptUnProtectData
(mais il doit exister pas loin d'une centaines de fonctions, de chiffrement,
hachage, certification, vérification de signature, ...)
En Delphi :
----------
function CryptProtectData(
pDataIn: PDATA_BLOB; //données à chiffer
szDataDescr: LPCWSTR; /description des données (optionnel)
pOptionalEntropy: PDATA_BLOB; //mot de passe supplémentaire ou netropei de
chiffremnt (optionnel)
pvReserved: pointer;
pPromptStruct: PCRYPTPROTECT_PROMPTSTRUCT; //paramètres de la boite de
dialogue apparaissant (optionnel)
dwFlags: DWORD; //paramètres de chiffrement (chiffrement lié à la machine
plutôt que l'utilisateur, audit, vérification ...
var pDataOut: DATA_BLOB // données chiffrées
): BOOL; stdcall;
function CryptUnprotectData(
pDataIn: PDATA_BLOB; // in encr blob
var ppszDataDescr: LPWSTR; // out
pOptionalEntropy: PDATA_BLOB;
pvReserved: pointer;
pPromptStruct: PCRYPTPROTECT_PROMPTSTRUCT;
dwFlags: DWORD;
var pDataOut: DATA_BLOB
): BOOL; stdcall;
ZeroMemory(&PromptStruct, sizeof(PromptStruct));
PromptStruct.cbSize = sizeof(PromptStruct);
PromptStruct.dwPromptFlags = CRYPTPROTECT_PROMPT_ON_PROTECT;
PromptStruct.szPrompt = L"This is a user prompt.";
//--------------------------------------------------------------------
// Begin protect phase.
if(CryptProtectData(
&DataIn,
L"This is the description string.", // A description string.
NULL, // Optional entropy not used.
NULL, // Reserved.
&PromptStruct, // Pass a PromptStruct.
0,
&DataOut))
{
printf("The encryption phase worked. n");
}
else
{
MyHandleError("Encryption error!");
}
//-----------------------------------------------------------------
// Begin unprotect phase.
if (CryptUnprotectData(
&DataOut,
&pDescrOut,
NULL, // Optional entropy
NULL, // Reserved
&PromptStruct, // Optional PromptStruct
0,
&DataVerify))
{
printf("The decrypted data is: %sn", DataVerify.pbData);
printf("The description of the data was: %Sn",pDescrOut);
}
else
{
MyHandleError("Decryption error!");
}
//-------------------------------------------------------------------
// At this point, memcmp could be used to compare DataIn.pbData and
// DataVerify.pbDate for equality. If the two functions worked
// correctly, the two byte strings are identical.
LocalFree(pDescrOut);
LocalFree(DataOut.pbData);
LocalFree(DataVerify.pbData);
} // End of main
//--------------------------------------------------------------------
// This example uses the function MyHandleError, a simple error
// handling function, to print an error message to the standard error
// (stderr) file and exit the program.
// For most applications, replace this function with one
// that does more extensive error reporting.
void MyHandleError(char *s)
{
fprintf(stderr,"An error occurred in running the program. n");
fprintf(stderr,"%sn",s);
fprintf(stderr, "Error number %x.n", GetLastError());
fprintf(stderr, "Program terminating. n");
exit(1);
} // End of MyHandleError
--
May the Force be with You!
La Connaissance s'accroît quand on la partage
----------------------------------------------------------
Jean-Claude BELLAMY [MVP] - http://www.bellamyjc.org
Jean-Claude.Bellamy@wanadoo.fr * JC.Bellamy@free.fr
Quelqu'un aurait-il des informations sur la Windows Crypt API (CAPI) pour crypter/décrypter des informations dans une application ? Est-elle disponible avec Windows 2000,
Oui, toutes les fonctions de chiffrement sont disponibles, et utilisables dans n'importe quelle appli (en VB, en C++, en Delphi,..) (je suis en train d'en écrire une en Delphi)
et comment l'utiliser ? Cela dépend du langage.
Sous Visual Studio (6 et .NET), c'est prévu d'origine (include "wincrypt.h", library "crypt32.lib") Sous Delphi, (V6 et antérieures), on peut trouver l'unité "qui va bien" chez un russe : http://codecentral.borland.com/codecentral/ccweb.exe/listing?id597
Il existe un grand nombre de fonctions
Les 2 plus "classiques" sont CryptProtectData CryptUnProtectData
(mais il doit exister pas loin d'une centaines de fonctions, de chiffrement, hachage, certification, vérification de signature, ...)
En Delphi : ---------- function CryptProtectData( pDataIn: PDATA_BLOB; //données à chiffer szDataDescr: LPCWSTR; /description des données (optionnel) pOptionalEntropy: PDATA_BLOB; //mot de passe supplémentaire ou netropei de chiffremnt (optionnel) pvReserved: pointer; pPromptStruct: PCRYPTPROTECT_PROMPTSTRUCT; //paramètres de la boite de dialogue apparaissant (optionnel) dwFlags: DWORD; //paramètres de chiffrement (chiffrement lié à la machine plutôt que l'utilisateur, audit, vérification ... var pDataOut: DATA_BLOB // données chiffrées ): BOOL; stdcall;
function CryptUnprotectData( pDataIn: PDATA_BLOB; // in encr blob var ppszDataDescr: LPWSTR; // out pOptionalEntropy: PDATA_BLOB; pvReserved: pointer; pPromptStruct: PCRYPTPROTECT_PROMPTSTRUCT; dwFlags: DWORD; var pDataOut: DATA_BLOB ): BOOL; stdcall;
ZeroMemory(&PromptStruct, sizeof(PromptStruct)); PromptStruct.cbSize = sizeof(PromptStruct); PromptStruct.dwPromptFlags = CRYPTPROTECT_PROMPT_ON_PROTECT; PromptStruct.szPrompt = L"This is a user prompt.";
//-------------------------------------------------------------------- // Begin protect phase.
if(CryptProtectData( &DataIn, L"This is the description string.", // A description string. NULL, // Optional entropy not used. NULL, // Reserved. &PromptStruct, // Pass a PromptStruct. 0, &DataOut)) { printf("The encryption phase worked. n"); } else { MyHandleError("Encryption error!"); } //----------------------------------------------------------------- // Begin unprotect phase.
if (CryptUnprotectData( &DataOut, &pDescrOut, NULL, // Optional entropy NULL, // Reserved &PromptStruct, // Optional PromptStruct 0, &DataVerify)) { printf("The decrypted data is: %sn", DataVerify.pbData); printf("The description of the data was: %Sn",pDescrOut); } else { MyHandleError("Decryption error!"); } //------------------------------------------------------------------- // At this point, memcmp could be used to compare DataIn.pbData and // DataVerify.pbDate for equality. If the two functions worked // correctly, the two byte strings are identical.
LocalFree(pDescrOut); LocalFree(DataOut.pbData); LocalFree(DataVerify.pbData); } // End of main
//-------------------------------------------------------------------- // This example uses the function MyHandleError, a simple error // handling function, to print an error message to the standard error // (stderr) file and exit the program. // For most applications, replace this function with one // that does more extensive error reporting.
void MyHandleError(char *s) { fprintf(stderr,"An error occurred in running the program. n"); fprintf(stderr,"%sn",s); fprintf(stderr, "Error number %x.n", GetLastError()); fprintf(stderr, "Program terminating. n"); exit(1); } // End of MyHandleError -- May the Force be with You! La Connaissance s'accroît quand on la partage ---------------------------------------------------------- Jean-Claude BELLAMY [MVP] - http://www.bellamyjc.org *