2017-03-09 05:12:04 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "libp2p/crypto/sha256.h"
|
|
|
|
|
|
|
|
int test_crypto_hashing_sha256() {
|
|
|
|
int array_length = 255;
|
|
|
|
char test_array[array_length];
|
|
|
|
|
|
|
|
for(int i = 0; i < array_length; i++) {
|
|
|
|
int j = i % 255;
|
|
|
|
test_array[i] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
char result_mac1[32];
|
|
|
|
char result_mac2[32];
|
|
|
|
|
2017-07-17 21:14:20 +00:00
|
|
|
libp2p_crypto_hashing_sha256((unsigned char*)&test_array[0], array_length, (unsigned char*)&result_mac1[0]);
|
|
|
|
libp2p_crypto_hashing_sha256((unsigned char*)&test_array[0], array_length, (unsigned char*)&result_mac2[0]);
|
2017-03-09 05:12:04 +00:00
|
|
|
|
|
|
|
if (memcmp(result_mac1, result_mac2, 32) != 0)
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|