本文整理汇总了C++中TextReader::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ TextReader::Open方法的具体用法?C++ TextReader::Open怎么用?C++ TextReader::Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextReader
的用法示例。
在下文中一共展示了TextReader::Open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestMD5
int TestMD5()
{
MD5Hash md5;
const char *teststring = NULL;
size_t length = 0;
/* These tests are from FIPS PUB 180-1 */
teststring = ""; length = strlen(teststring);
md5.Process(teststring, length);
TEST_ASSERT(strcmp(md5.ToString(), "d41d8cd98f00b204e9800998ecf8427e") == 0);
teststring = "a"; length = strlen(teststring);
md5.Process(teststring, length);
TEST_ASSERT(strcmp(md5.ToString(), "0cc175b9c0f1b6a831c399e269772661") == 0);
teststring = "abc"; length = strlen(teststring);
md5.Process(teststring, length);
TEST_ASSERT(strcmp(md5.ToString(), "900150983cd24fb0d6963f7d28e17f72") == 0);
teststring = "message digest"; length = strlen(teststring);
md5.Process(teststring, length);
TEST_ASSERT(strcmp(md5.ToString(), "f96b697d7cb7938d525a2f31aaf161d0") == 0);
teststring = "abcdefghijklmnopqrstuvwxyz"; length = strlen(teststring);
md5.Process(teststring, length);
TEST_ASSERT(strcmp(md5.ToString(), "c3fcd3d76192e4007dfb496cca67e13b") == 0);
teststring = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; length = strlen(teststring);
md5.Process(teststring, length);
TEST_ASSERT(strcmp(md5.ToString(), "d174ab98d277d9f5a5611c2c9f419d9f") == 0);
teststring = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"; length = strlen(teststring);
md5.Process(teststring, length);
TEST_ASSERT(strcmp(md5.ToString(), "57edf4a22be3c955ac49da2e2107b67a") == 0);
MD5Hash otherhash;
otherhash.Process("cheese", 6);
TEST_ASSERT(otherhash != md5 && md5 != otherhash);
otherhash.Process(teststring, length);
TEST_ASSERT(otherhash == md5 && md5 == otherhash);
#ifdef FILE_CHECKSUM
TextReader file;
file.Open("testfile");
md5.Process((CoreIOReader *)&file);
TEST_ASSERT(strcmp(md5.ToString(), "bc2471d759c6ae2eb44482f571b02a40") == 0);
#endif
return 0;
}
示例2: TestSHA1
int TestSHA1()
{
SHA1Hash sha1;
const char *teststring = NULL;
size_t length = 0;
/* These tests are from FIPS PUB 180-1 */
teststring = "abc"; length = strlen(teststring);
sha1.Process(teststring, length);
TEST_ASSERT(strcmp(sha1.ToString(), "a9993e364706816aba3e25717850c26c9cd0d89d") == 0);
teststring = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; length = strlen(teststring);
sha1.Process(teststring, length);
TEST_ASSERT(strcmp(sha1.ToString(), "84983e441c3bd26ebaae4aa1f95129e5e54670f1") == 0);
SHA1Hash otherhash;
otherhash.Process("cheese", 6);
TEST_ASSERT(otherhash != sha1 && sha1 != otherhash);
otherhash.Process(teststring, length);
TEST_ASSERT(otherhash == sha1 && sha1 == otherhash);
#ifdef HIGH_INTENSITY
char *tempstring = new char[1000001];
memset(tempstring, 'a', 1000000);
tempstring[1000000] = '\0';
length = strlen(tempstring);
sha1.Process(tempstring, length);
TEST_ASSERT(strcmp(sha1.ToString(), "34aa973cd4c4daa4f61eeb2bdbad27316534016f") == 0);
delete [] tempstring;
#endif
#ifdef FILE_CHECKSUM
TextReader file;
file.Open("testfile");
sha1.Process((CoreIOReader *)&file);
TEST_ASSERT(strcmp(sha1.ToString(), "951a6307067df1931ee1637a57ea4b9ad4a01a7c") == 0);
#endif
return 0;
}
示例3: TestSHA256
int TestSHA256()
{
SHA256Hash sha256;
const char *teststring = NULL;
size_t length = 0;
/* These tests are from FIPS PUB 180-1 */
teststring = "abc"; length = strlen(teststring);
sha256.Process(teststring, length);
TEST_ASSERT(strcmp(sha256.ToString(), "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad") == 0);
teststring = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; length = strlen(teststring);
sha256.Process(teststring, length);
TEST_ASSERT(strcmp(sha256.ToString(), "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1") == 0);
SHA256Hash otherhash;
otherhash.Process("cheese", 6);
TEST_ASSERT(otherhash != sha256 && sha256 != otherhash);
otherhash.Process(teststring, length);
TEST_ASSERT(otherhash == sha256 && sha256 == otherhash);
#ifdef HIGH_INTENSITY
char *tempstring = new char[1000001];
memset(tempstring, 'a', 1000000);
tempstring[1000000] = '\0';
length = strlen(tempstring);
sha256.Process(tempstring, length);
TEST_ASSERT(strcmp(sha256.ToString(), "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0") == 0);
delete [] tempstring;
#endif
#ifdef FILE_CHECKSUM
TextReader file;
file.Open("testfile");
sha256.Process((CoreIOReader *)&file);
TEST_ASSERT(strcmp(sha256.ToString(), "e6f106d98b2937a68a1700c747e37c4d942a364ee0a529cb5b49e9e4cf66b7fe") == 0);
#endif
return 0;
}