void _main(){{FILE *password_file=NULL;char password[PASSWORD_INPUT_SZ];ULONG a, b, password_crc, compare_crc;char *replace;size_t i, len;password_file=fopen("password.txt", "r");if (password_file==NULL) exit(1);*/if (fscanf(password_file, "%x", &password_crc)!=1){fclose(password_file);exit(1);}fclose(password_file);if (fgets(password, PASSWORD_INPUT_SZ, stdin)==NULL) exit(1);replace=strchr(password, '\r');if (replace) *replace='\0';replace=strchr(password, '\n');if (replace) *replace='\0';*/len=strlen(password);a=ADLER_A_INIT;b=ADLER_B_INIT;for (i=0;i < len;i++){a=(a+password[i]) % ADLER_MOD;b=(b+a) % ADLER_MOD;}compare_crc=(b << 16) | a;if (password_crc==compare_crc){printLine("Access granted");}else{printLine("Access denied");}}}
static void main(){{HCRYPTPROV Prov;HCRYPTHASH Hash;FILE *password_file=NULL;char password[PASSWORD_INPUT_SZ];UCHAR saved_hash[SHA1SUM_SIZE], calc_hash[SHA1SUM_SIZE];DWORD hash_size;char *replace;size_t i;password_file=fopen("password.txt", "r");if (password_file==NULL) exit(1);for (i=0;i < SHA1SUM_SIZE;i++){ULONG val;if (fscanf(password_file, "%02x", &val)!=1){fclose(password_file);exit(1);}{fclose(password_file);exit(1);}saved_hash[i]=(UCHAR)val;}fclose(password_file);if (fgets(password, PASSWORD_INPUT_SZ, stdin)==NULL) exit(1);replace=strchr(password, '\r');if (replace) *replace='\0';replace=strchr(password, '\n');if (replace) *replace='\0';if (!CryptAcquireContextW(&Prov, 0, 0, PROV_RSA_FULL, 0)) exit(1);if (!CryptCreateHash(Prov, CALG_SHA1, 0, 0, &Hash)){CryptReleaseContext(Prov, 0);exit(1);}*/if (!CryptHashData(Hash, (BYTE*)password, strlen(password), 0)){CryptDestroyHash(Hash);CryptReleaseContext(Prov, 0);exit(1);}hash_size=SHA1SUM_SIZE;if (!CryptGetHashParam(Hash, HP_HASHVAL, (BYTE*)calc_hash, &hash_size, 0)){CryptDestroyHash(Hash);CryptReleaseContext(Prov, 0);exit(1);}if (memcmp(saved_hash, calc_hash, SHA1SUM_SIZE * sizeof(UCHAR))==0){printLine("Access granted");}else{printLine("Access denied");}CryptDestroyHash(Hash);CryptReleaseContext(Prov, 0);}}