bool dcrypt(const uint8_t *data, size_t data_sz, uint8_t *hash_digest, u32int *hashRet, int num_iter) { uint8_t hashed_nums[SHA256_LEN + 1], *mix_hash; bool allocDigest = false; bool completed = false; if(!hash_digest) { hash_digest = alloca(DCRYPT_DIGEST_LENGTH); allocDigest = true; } sha256_to_str(data, data_sz, hashed_nums, hash_digest); //mix the hashes up, magority of the time takes here uint64 mix_hash_len = mix_hashed_nums(hashed_nums, data, data_sz, &mix_hash, hash_digest, num_iter, &completed); //apply the final hash to the output if (completed) sha256((const uint8_t*)mix_hash, mix_hash_len, hashRet); free(mix_hash); //sucess return completed; }
void dcrypt(const uint8_t *data, size_t data_sz, uint8_t *hash_digest, uint32_t *hashRet) { uint8_t hashed_nums[SHA256_LEN + 1], *mix_hash; bool allocDigest = false; if(!hash_digest) { hash_digest = (uint8_t*)malloc(DCRYPT_DIGEST_LENGTH); allocDigest = true; } sha256_to_str(data, data_sz, hashed_nums, hash_digest); //mix the hashes up, magority of the time takes here uint64_t mix_hash_len = mix_hashed_nums(hashed_nums, data, data_sz, &mix_hash, hash_digest); //apply the final hash to the output sha256((const uint8_t*)mix_hash, mix_hash_len, hashRet); free(mix_hash); if(allocDigest) free(hash_digest); //sucess return; }