本文整理汇总了C++中QSharedPointer::Encrypt方法的典型用法代码示例。如果您正苦于以下问题:C++ QSharedPointer::Encrypt方法的具体用法?C++ QSharedPointer::Encrypt怎么用?C++ QSharedPointer::Encrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSharedPointer
的用法示例。
在下文中一共展示了QSharedPointer::Encrypt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Shuffle
virtual void Shuffle()
{
Random &rand = Random::GetInstance();
if((rand.GetInt(0, 1024) / 1024.0) > N) {
ShuffleRound::Shuffle();
return;
}
SetTriggered();
QVector<QSharedPointer<AsymmetricKey> > outer_keys;
for(int idx = GetShufflers().Count() - 1;
idx >= GetShufflers().GetIndex(GetLocalId()); idx--)
{
int kidx = CalculateKidx(idx);
outer_keys.append(_state->public_outer_keys[kidx]);
}
QByteArray get_data = DefaultData;
QByteArray inner_ct, outer_ct;
QSharedPointer<OnionEncryptor> oe;
if(Utils::MultiThreading) {
oe = QSharedPointer<OnionEncryptor>(new ThreadedOnionEncryptor());
} else {
oe = QSharedPointer<OnionEncryptor>(new OnionEncryptor());
}
oe->Encrypt(_state->public_inner_keys, get_data, inner_ct, 0);
oe->Encrypt(outer_keys, inner_ct, outer_ct, 0);
int x = Random::GetInstance().GetInt(0,
_server_state->shuffle_input.count());
_server_state->shuffle_input[x] = outer_ct;
ShuffleRound::Shuffle();
}
示例2: SubmitCiphertext
virtual void SubmitCiphertext()
{
Random &rand = Random::GetInstance();
if((rand.GetInt(0, 1024) / 1024.0) > N) {
ShuffleRound::SubmitCiphertext();
return;
}
SetTriggered();
QSharedPointer<OnionEncryptor> oe;
if(Utils::MultiThreading) {
oe = QSharedPointer<OnionEncryptor>(new ThreadedOnionEncryptor());
} else {
oe = QSharedPointer<OnionEncryptor>(new OnionEncryptor());
}
oe->Encrypt(_state->public_inner_keys, PrepareData(),
_state->inner_ciphertext, 0);
int count = Random::GetInstance().GetInt(0, GetShufflers().Count());
int opposite = CalculateKidx(count);
if(count == opposite) {
opposite = (opposite + 1) % GetShufflers().Count();
}
QSharedPointer<AsymmetricKey> tmp(_state->public_outer_keys[opposite]);
_state->public_outer_keys[opposite] = _state->public_outer_keys[count];
QByteArray outer_ciphertext;
oe->Encrypt(_state->public_outer_keys, _state->inner_ciphertext,
outer_ciphertext, 0);
_state->public_outer_keys[opposite] = tmp;
QByteArray msg;
QDataStream stream(&msg, QIODevice::WriteOnly);
stream << DATA << GetRoundId() << outer_ciphertext;
VerifiableSend(GetShufflers().GetId(0), msg);
_state_machine.StateComplete();
}