Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sha1.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <string>
#include <websocketpp/sha1/sha1.hpp>
#include <websocketpp/utilities.hpp>
Include dependency graph for sha1.cpp:

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   sha1
 

Functions

 BOOST_AUTO_TEST_CASE (sha1_test_a)
 
 BOOST_AUTO_TEST_CASE (sha1_test_b)
 
 BOOST_AUTO_TEST_CASE (sha1_test_c)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   sha1

Definition at line 28 of file sha1.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( sha1_test_a )

Definition at line 39 of file sha1.cpp.

39 {
40 unsigned char hash[20];
41 unsigned char reference[20] = {0xa9, 0x99, 0x3e, 0x36, 0x47,
42 0x06, 0x81, 0x6a, 0xba, 0x3e,
43 0x25, 0x71, 0x78, 0x50, 0xc2,
44 0x6c, 0x9c, 0xd0, 0xd8, 0x9d};
45
46 websocketpp::sha1::calc("abc",3,hash);
47
48 BOOST_CHECK_EQUAL_COLLECTIONS(hash, hash+20, reference, reference+20);
49}
void calc(void const *src, size_t bytelength, unsigned char *hash)
Calculate a SHA1 hash.
Definition sha1.hpp:127
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( sha1_test_b )

Definition at line 51 of file sha1.cpp.

51 {
52 unsigned char hash[20];
53 unsigned char reference[20] = {0x84, 0x98, 0x3e, 0x44, 0x1c,
54 0x3b, 0xd2, 0x6e, 0xba, 0xae,
55 0x4a, 0xa1, 0xf9, 0x51, 0x29,
56 0xe5, 0xe5, 0x46, 0x70, 0xf1};
57
59 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",56,hash);
60
61 BOOST_CHECK_EQUAL_COLLECTIONS(hash, hash+20, reference, reference+20);
62}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( sha1_test_c )

Definition at line 64 of file sha1.cpp.

64 {
65 std::string input;
66 unsigned char hash[20];
67 unsigned char reference[20] = {0x34, 0xaa, 0x97, 0x3c, 0xd4,
68 0xc4, 0xda, 0xa4, 0xf6, 0x1e,
69 0xeb, 0x2b, 0xdb, 0xad, 0x27,
70 0x31, 0x65, 0x34, 0x01, 0x6f};
71
72 for (int i = 0; i < 1000000; i++) {
73 input += 'a';
74 }
75
76 websocketpp::sha1::calc(input.c_str(),input.size(),hash);
77
78 BOOST_CHECK_EQUAL_COLLECTIONS(hash, hash+20, reference, reference+20);
79}
Here is the call graph for this function: