//ver- und wieder entschlüsseln eines Strings mit einem Passwort #include #include #include // lc cryptencryptdata.c advapi32.lib //---------------------------------------------------------------------------- void CryptandEncryptData(BYTE Buf[100],char *Password) { HCRYPTPROV hProv; HCRYPTHASH hPwdHash; HCRYPTKEY hKey; DWORD DataLen; DWORD i; DataLen = lstrlen(Buf)+1; printf("vorher:\t\t%s\n",Buf); if(!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0)) { printf("error: %d\n",GetLastError()); exit(1); } if(!CryptCreateHash(hProv, CALG_MD5, 0, 0, &hPwdHash)) { printf("error: %d\n",GetLastError()); CryptReleaseContext(hProv, 0); exit(1); } if(!CryptHashData(hPwdHash, Password, lstrlen(Password)+1, 0)) { printf("error: %d\n",GetLastError()); CryptDestroyHash(hPwdHash); CryptReleaseContext(hProv, 0); exit(1); } if(!CryptDeriveKey(hProv, CALG_RC4, hPwdHash, CRYPT_CREATE_SALT, &hKey)) { printf("error: %d\n",GetLastError()); CryptDestroyHash(hPwdHash); CryptReleaseContext(hProv, 0); exit(1); } printf("CryptDeriveKey:\t"); for(i=0; i