本文整理汇总了C++中CByteArray::Equals方法的典型用法代码示例。如果您正苦于以下问题:C++ CByteArray::Equals方法的具体用法?C++ CByteArray::Equals怎么用?C++ CByteArray::Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CByteArray
的用法示例。
在下文中一共展示了CByteArray::Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestPteidCtrl
static long TestPteidCtrl(CReader & oReader, unsigned char ucVersion)
{
long lErrors = 0;
printf("\nTesting Ctrl()\n");
// CTRL_PTEID_GETCARDDATA
CByteArray oCardInfo = oReader.GetInfo();
CByteArray oUnsignedCardData = oReader.Ctrl(CTRL_PTEID_GETCARDDATA, CByteArray());
if (!oCardInfo.Equals(oUnsignedCardData))
ERR_LOG("ERR: Ctrl(CTRL_PTEID_GETCARDDATA) != GetInfo()\n", lErrors);
// CTRL_PTEID_GETSIGNEDCARDDATA
if (ucVersion >= 0x20)
{
CByteArray oSignedCardData = oReader.Ctrl(CTRL_PTEID_GETSIGNEDCARDDATA, CByteArray());
if (oSignedCardData.Size() != oUnsignedCardData.Size() + 128)
ERR_LOG("ERR: signed and unsigned card data should differ in size by 128 bytes\n", lErrors);
oSignedCardData.Chop(128);
if (!oUnsignedCardData.Equals(oSignedCardData))
ERR_LOG("ERR: start of unsigned card data should be the same as for unsigned card data\n", lErrors);
}
// CTRL_PTEID_GETSIGNEDPINSTATUS
if (ucVersion >= 0x20)
{
tPin pin = oReader.GetPin(0);
CByteArray oData(1);
oData.Append((unsigned char) pin.ulPinRef);
CByteArray oSignedPinStatus = oReader.Ctrl(CTRL_PTEID_GETSIGNEDPINSTATUS, oData);
if (oSignedPinStatus.Size() != 129)
ERR_LOG("ERR: signed pin status response should be (1 + 128) bytes\n", lErrors);
else if (oSignedPinStatus.GetByte(0) != oReader.PinStatus(pin))
ERR_LOG("ERR: signed pin status differs from unsigned PIN status\n", lErrors);
}
// CTRL_PTEID_INTERNAL_AUTH
CByteArray oData(21); // Key ref (1 byte) + challenge(20 bytes)
oData.Append(0x81);
for (int i = 0; i < 20; i++)
oData.Append((unsigned char) rand());
CByteArray oResp1 = oReader.Ctrl(CTRL_PTEID_INTERNAL_AUTH, oData);
if (oResp1.Size() != 128)
ERR_LOG("ERR: Internal Auth. didn't return 128 bytes\n", lErrors);
CByteArray oResp2 = oReader.Ctrl(CTRL_PTEID_INTERNAL_AUTH, oData);
if (!oResp1.Equals(oResp2))
ERR_LOG("ERR: Internal Auth. on the same data returns a different result\n", lErrors);
oData.SetByte(oData.GetByte(5) + 0x01, 5);
CByteArray oResp3 = oReader.Ctrl(CTRL_PTEID_INTERNAL_AUTH, oData);
if (oResp1.Equals(oResp3))
ERR_LOG("ERR: Internal Auth. on the different data returns the same result\n", lErrors);
return lErrors;
}
示例2: TestCache
/**
* csPath should be the path to a big file that can be cached
* Best do this test first, because anything is cached.
*/
static long TestCache(CReader & oReader, const std::string & csPath)
{
long lErrors = 0;
printf("\nTesting caching functionality (using file %s)\n", csPath.c_str());
CByteArray oMaybeFromDisk = oReader.ReadFile(csPath);
bool bDeleted = g_oCardLayer.DeleteFromCache(oReader.GetSerialNr());
if (!bDeleted)
{
ERR_LOG("ERR: CCardLayer::DeleteFromCache() seems to fail\n", lErrors);
printf(" (File %s should have been cached, but isn't deleted)\n", csPath.c_str());
}
CByteArray oFromCard = oReader.ReadFile(csPath);
//diffFromCard = fromCard2 - fromCard1;
CByteArray oFromMem = oReader.ReadFile(csPath);
//diffFromMem = fromMem2 - fromMem1;
/*
if (2 * diffFromMem > diffFromCard)
{
printf("WARNING: reading %d bytes from the card (%d msec) isn't much\n",
oFromCard.Size(), diffFromCard);
printf(" faster then reading it from cach (%d msec)\n", diffFromMem);
}
*/
if (!oFromCard.Equals(oFromMem))
ERR_LOG("ERR: cached file contents (from memory) differ from those on the card\n", lErrors);
else if (!oFromCard.Equals(oMaybeFromDisk))
ERR_LOG("ERR: cached file contents (from disk) differ from those on the card\n", lErrors);
oFromCard = oReader.ReadFile(csPath, 10, 20);
oFromMem = oReader.ReadFile(csPath, 10, 20);
if (!oFromCard.Equals(oFromMem))
ERR_LOG("ERR: reading part of the cached contents fails\n", lErrors);
return lErrors;
}