Is there something that I need to install or set up on my computer
before using the CryptoAPI functions in Delphi (5)?
Or do I need a higher version of Delphi to make it work?
Thanks very much in advance,
Carmen
> But the program failed right after calling
> CryptAcquireContext.
This doesn't give us any useful information.
If CryptAcquireContext fails, you are supposed to call GetLastError to
retrieve the error code, this might give you (and us) an indication why
it fails.
> Is there something that I need to install or set up on my computer
> before using the CryptoAPI functions in Delphi (5)?
Not really, unless your OS predates Win98.
> Or do I need a higher version of Delphi to make it work?
No, D5 is fine.
Danny
---
Danny,
In hexadecimal it is 0x80090016 -- is this less strange?
You may want to review
http://www.google.com/search?q=0x80090016+CryptAcquireContext
HTH, JohnH
Thanks for the reply.
The error code returned after CryptAcquireContext is: 2148073494. It seems
like a really strange error code.
Here is the code:
procedure TmainForm.initAPI(Key: String);
var errCode: DWORD;
begin
hProv:=0;
hKey:=0;
hHash:=0;
if NOT CryptAcquireContext(@hProv, nil, nil, PROV_RSA_FULL, 0) then
begin
errCode:= GetLastError;
showMessage('CryptoAPI error during: CryptAcquireContext '+
IntToStr(errCode));
end;
...
end; // initAPI
Regards,
Carmen
"danny heijl" <danny_dot_heijl_at_cevi_dot_be> wrote in message
news:45a3c1fd$1...@newsgroups.borland.com...
> The error code returned after CryptAcquireContext is: 2148073494. It seems
> like a really strange error code.
The error code (NTE_BAD_KEYSET) tells you that you don't have 'default'
container in the CSP. If you don't need one you should use the
CRYPT_VERIFYCONTEXT flag in CryptAcquireContext.
Danny
---
One more question, I have a Visual Studio .NET program which uses the
DESCryptoServiceProvider class to encrypt/decrypt files (which requires a
key and an initialization vector). Does the CryptoAPI have anything that is
equivalent to this? Basically I want to be able to decrypt a file with the
same key in both the Delphi and .NET programs.
Thanks very much!
Carmen
"danny heijl" <danny_dot_heijl_at_telenet_dot_be> wrote in message
news:45a3...@newsgroups.borland.com...
> I have a Visual Studio .NET program which uses the
> DESCryptoServiceProvider class to encrypt/decrypt files (which requires a
> key and an initialization vector). Does the CryptoAPI have anything that is
> equivalent to this?
Yes, as the .Net crypto classes mostly use the CryptoApi internally (but
in some cases extend it substantially). CryptEncrypt encrypts, and when
creating the session key with CryptDeriveKey you specify the encryption
algorithm to be used.
Danny
---
Thanks again,
Carmen
"danny heijl" <danny_dot_heijl_at_cevi_dot_be> wrote in message
news:45a49ee6$1...@newsgroups.borland.com...
> So how does a
> key and an IV in .NET equate to a single password or key in CryptEncrypt?
You use CryptSetKeyParam once you have the handle to the key.
Danny
---
> This is what confuses me.
Then perhaps you should read this first:
http://www.jensign.com/JavaScience/dotnet/NetDESEncrypt/index.html
Danny
---