本文整理汇总了C++中ustring::getRest方法的典型用法代码示例。如果您正苦于以下问题:C++ ustring::getRest方法的具体用法?C++ ustring::getRest怎么用?C++ ustring::getRest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ustring
的用法示例。
在下文中一共展示了ustring::getRest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadAddr
bool PubAddr::loadAddr(ustring address)
{
unsigned int i = 0;
string BM = address.getString(3, i);
if (strncmp(BM.c_str(), "BM-", 3) != 0)
{
i = 0;
}
char retu[100];
size_t size2 = 50;
if (b58tobin(retu, &size2, (char *)address.getRest(i).c_str()) != true)
{
return false; //ignoring key not valid
}
ustring _buffer;
retu[size2] = 0x00;
for (unsigned int j = 0; j < size2; j++)
_buffer += retu[j];
i = 0;
unsigned int checkPos = _buffer.length() - 4;
if (checkPos < (unsigned int)0)
return false;
ustring buffer = _buffer.getUstring(checkPos, i);
byte checksum[4];
memcpy(checksum, _buffer.getUstring(4, checkPos).c_str(), sizeof checksum);
CryptoPP::SHA512 hash;
byte digest[CryptoPP::SHA512::DIGESTSIZE];
byte digest2[CryptoPP::SHA512::DIGESTSIZE];
hash.CalculateDigest(digest, (byte*)buffer.c_str(), buffer.length());
hash.CalculateDigest(digest2, digest, sizeof digest);
if (memcmp(digest2, checksum, sizeof checksum)!=0)
{
return false; //ignoring key not valid
}
i = 0;
std::unique_lock<std::shared_timed_mutex> mlock(this->mutex_);
this->address = address;
int tmp_vers = (int)buffer.getVarInt_B(i);
int tmp_stream = (int)buffer.getVarInt_B(i);
ustring tmp_ripe = buffer.getRest(i);
if (tmp_ripe.length() > 20)
return false; //too long
if (tmp_ripe.length() < 4)
return false; //too short
this->version = tmp_vers;
this->stream = tmp_stream;
while (tmp_ripe.length() != 20) //todo add function prepend
{
ustring tmp2;
tmp2.appendInt8(0);
tmp2+=tmp_ripe;
tmp_ripe = tmp2;
}
this->ripe.clear();
this->ripe = tmp_ripe;
buffer.clear();
buffer.appendVarInt_B(this->version);
buffer.appendVarInt_B(this->stream);
buffer += this->ripe;
hash.CalculateDigest(digest, (byte*)buffer.c_str(), buffer.length());
hash.CalculateDigest(digest2, digest, sizeof digest);
this->tagE.clear();
this->tagE.append(digest2, 32);
this->tag.clear();
this->tag.append(&(digest2[32]), 32);
this->empty = true;
mlock.unlock();
return true;
}