wincrypt.h equivalent on linux

1
2
3
4
5
6
7
8
9
10
11
12
13
14
HCRYPTPROV ctx;
HCRYPTHASH hash;
HCRYPTKEY key;
char data[32] = "Some data";
DWORD len = strlen(data);

CryptAcquireContext(&ctx, 0, "Microsoft Base Cryptographic Provider v1.0", 1, CRYPT_VERIFYCONTEXT);
CryptCreateHash(ctx, CALG_MD5, 0, 0, &hash);
CryptHashData(hash, "mykey", 5, 0);
CryptDeriveKey(ctx, CALG_RC4, hash, 4, &key);
CryptDecrypt(key, 0, 0, 0, (BYTE *)data, &len);
CryptDestroyKey(key);
CryptDestroyHash(hash);
CryptReleaseContext(ctx);


This is what I use on Windows to encrypt/decrypt certain files. On Linux, I've tried OpenSSL functions MD5(..) and RC4(..) but they didn't produce the same output. Does anyone know an equivalent of code above on Linux?
Last edited on
Important This API is deprecated. New and existing software should start using Cryptography Next Generation APIs. Microsoft may remove this API in future releases.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa379886(v=vs.85).aspx

Why do you want to use a deprecated crypto API?

In any event, if you want the benefits of an open system, you need to use open, not proprietary, software.
Last edited on
Topic archived. No new replies allowed.