Пример #1
0
void test_sha512_256() {
	const char * tests[4] = {
		"", "A", "0123456789", "abcdefghijklmnopqrstuvwxyz"
	};
	const char * oks[4] = {
		"c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a",
		"65a992ad19967492b5780d76a4733af553f796f688b79102d01ec7fde5590cab",
		"d48b2aa4a50d1c3e324a1a762d3b2165244661ef80e004dd3669a77e02c489d8",
		"fc3189443f9c268f626aea08a756abe7b726b05f701cb08222312ccfd6710a26"
	};
	uint8_t hash[SHA512_256_HASH_SIZE];
	char string[SHA512_256_STRING_HASH_SIZE];
	int i;
	puts("\n\nTesting SHA512/256...\n");
	for (i = 0; i < 4; i++) {
		sha512_256(tests[i], strlen(tests[i]), hash);
		sha512_256_hash_to_string(hash, string);
		printf("%s\n%s\n--> %s\n\n", tests[i], string, strcmp(string, oks[i]) == 0 ? "OK" : "FAIL");
	}
	puts("\nTest done.\n");
}
Пример #2
0
	void HashFunctions::sha512_256(const std::string &data, unsigned char out_hash[32])
	{
		sha512_256(data.data(), data.length(), out_hash);
	}
Пример #3
0
	void HashFunctions::sha512_256(const DataBuffer &data, unsigned char out_hash[32])
	{
		sha512_256(data.get_data(), data.get_size(), out_hash);
	}
Пример #4
0
	std::string HashFunctions::sha512_256(const DataBuffer &data, bool uppercase)
	{
		return sha512_256(data.get_data(), data.get_size(), uppercase);
	}
Пример #5
0
	std::string HashFunctions::sha512_256(const std::string &data, bool uppercase)
	{
		return sha512_256(data.data(), data.length(), uppercase);
	}