void _main(){{FILE *file;char encrypted_block[BLOCK_SZ+1];char decrypted_block[BLOCK_SZ+1];size_t i;file=fopen("encrypted.txt", "rb");if (file==NULL) exit(1);if (fread(encrypted_block, sizeof(char), BLOCK_SZ, file)!=BLOCK_SZ){fclose(file);exit(1);}encrypted_block[BLOCK_SZ]='\0';decrypted_block[BLOCK_SZ]='\0';for (i=0;i < BLOCK_SZ;i++){char c=encrypted_block[i];if ((c < 'A' || c > 'Z')){fclose(file);}if (c >='A' && c <='Z'){c=c-'A'-13;if (c < 0) c+=26;c=c+'A';}decrypted_block[i]=c;}printLine(decrypted_block);fclose(file);}}
static void main(){{FILE *file;HCRYPTPROV cryptoprov;HCRYPTKEY key;HCRYPTHASH hash;char password[100];size_t password_len;char toBeDecrypted[100];DWORD toBeDecryptedLen=sizeof(toBeDecrypted)-1;printLine("Enter the password: ");fgets(password, 100, stdin);password_len=strlen(password);if (password_len > 0){password[password_len-1]='\0';}file=fopen("encrypted.txt", "rb");if (file==NULL) exit(1);if (fread(toBeDecrypted, sizeof(char), 100, file)!=100){fclose(file);exit(1);}toBeDecrypted[99]='\0';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 *) password, password_len, 0)){printLine("Error in hashing password");exit(1);}if(!CryptDeriveKey(cryptoprov, CALG_3DES, hash, 0, &key)){printLine("Error in CryptDeriveKey");exit(1);}if(!CryptDecrypt(key, 0, 1, 0, (BYTE *)toBeDecrypted, &toBeDecryptedLen)){printLine("Error in decryption");exit(1);}printLine(toBeDecrypted);CryptReleaseContext(cryptoprov,0);CryptDestroyHash(hash);CryptDestroyKey(key);fclose(file);}}