当前位置: 首页>>代码示例>>C++>>正文


C++ QSharedPointer::Encrypt方法代码示例

本文整理汇总了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();
      }
开发者ID:applsdev,项目名称:Dissent,代码行数:35,代码来源:ShuffleRoundHelpers.hpp

示例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();
      }
开发者ID:applsdev,项目名称:Dissent,代码行数:39,代码来源:ShuffleRoundHelpers.hpp


注:本文中的QSharedPointer::Encrypt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。