static wchar_t * main_source(wchar_t * cryptokey){wcscpy(cryptokey, CRYPTOKEY);return cryptokey;}void _main(){wchar_t * cryptokey;wchar_t cryptokey_buf[100]=L"";cryptokey=cryptokey_buf;cryptokey=main_source(cryptokey);{HCRYPTPROV cryptoprov;HCRYPTKEY key;HCRYPTHASH hash;DWORD toBeEncryptedLen=wcslen(toBeEncrypted)*sizeof(wchar_t);if(!CryptAcquireContext(&cryptoprov, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, 0)){if(!CryptAcquireContext(&cryptoprov, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET)){printLine("Error in acquiring cryptographic context");exit(1);}}if(!CryptCreateHash(cryptoprov, CALG_SHA1, 0, 0, &hash)){printLine("Error in creating hash");exit(1);}if(!CryptHashData(hash, (BYTE *) cryptokey, wcslen(cryptokey)*sizeof(wchar_t), 0)){printLine("Error in hashing cryptokey");exit(1);}if(!CryptDeriveKey(cryptoprov, CALG_3DES, hash, 0, &key)){printLine("Error in CryptDeriveKey");exit(1);}if(!CryptEncrypt(key, (HCRYPTHASH)NULL, 1, 0, (BYTE *)toBeEncrypted, &toBeEncryptedLen, sizeof(toBeEncrypted))){printLine("Error in CryptEncryptData");exit(1);}printWLine(toBeEncrypted);}}
static wchar_t * main_source(wchar_t * cryptokey){{size_t cryptokey_len=wcslen(cryptokey);if(100-cryptokey_len > 1){fgetws(cryptokey+cryptokey_len, (int)(100-cryptokey_len), stdin);cryptokey_len=wcslen(cryptokey);if (cryptokey_len > 0){cryptokey[cryptokey_len-1]=L'\0';}}}return cryptokey;}static void main(){wchar_t * cryptokey;wchar_t cryptokey_buf[100]=L"";cryptokey=cryptokey_buf;cryptokey=main_source(cryptokey);{HCRYPTPROV cryptoprov;HCRYPTKEY key;HCRYPTHASH hash;DWORD toBeEncryptedLen=wcslen(toBeEncrypted)*sizeof(wchar_t);if(!CryptAcquireContext(&cryptoprov, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, 0)){if(!CryptAcquireContext(&cryptoprov, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET)){printLine("Error in acquiring cryptographic context");exit(1);}}if(!CryptCreateHash(cryptoprov, CALG_SHA1, 0, 0, &hash)){printLine("Error in creating hash");exit(1);}if(!CryptHashData(hash, (BYTE *) cryptokey, wcslen(cryptokey)*sizeof(wchar_t), 0)){printLine("Error in hashing cryptokey");exit(1);}if(!CryptDeriveKey(cryptoprov, CALG_3DES, hash, 0, &key)){printLine("Error in CryptDeriveKey");exit(1);}if(!CryptEncrypt(key, (HCRYPTHASH)NULL, 1, 0, (BYTE *)toBeEncrypted, &toBeEncryptedLen, sizeof(toBeEncrypted))){printLine("Error in CryptEncryptData");exit(1);}printWLine(toBeEncrypted);}}