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


C++ CItemEx::IsEncrypted方法代码示例

本文整理汇总了C++中CItemEx::IsEncrypted方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemEx::IsEncrypted方法的具体用法?C++ CItemEx::IsEncrypted怎么用?C++ CItemEx::IsEncrypted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CItemEx的用法示例。


在下文中一共展示了CItemEx::IsEncrypted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Decode

HRESULT CZipDecoder::Decode(
    DECL_EXTERNAL_CODECS_LOC_VARS
    CInArchive &archive, const CItemEx &item,
    ISequentialOutStream *realOutStream,
    IArchiveExtractCallback *extractCallback,
    ICompressProgressInfo *compressProgress,
    UInt32 numThreads, Int32 &res)
{
  res = NArchive::NExtract::NOperationResult::kDataError;
  CInStreamReleaser inStreamReleaser;

  bool needCRC = true;
  bool wzAesMode = false;
  bool pkAesMode = false;
  UInt16 methodId = item.CompressionMethod;
  if (item.IsEncrypted())
  {
    if (item.IsStrongEncrypted())
    {
      CStrongCryptoField f;
      if (item.CentralExtra.GetStrongCryptoField(f))
      {
        pkAesMode = true;
      }
      if (!pkAesMode)
      {
        res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
        return S_OK;
      }
    }
    if (methodId == NFileHeader::NCompressionMethod::kWzAES)
    {
      CWzAesExtraField aesField;
      if (item.CentralExtra.GetWzAesField(aesField))
      {
        wzAesMode = true;
        needCRC = aesField.NeedCrc();
      }
    }
  }
    
  COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
  CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
  outStreamSpec->SetStream(realOutStream);
  outStreamSpec->Init(needCRC);
  
  UInt64 authenticationPos;
  
  CMyComPtr<ISequentialInStream> inStream;
  {
    UInt64 packSize = item.PackSize;
    if (wzAesMode)
    {
      if (packSize < NCrypto::NWzAes::kMacSize)
        return S_OK;
      packSize -= NCrypto::NWzAes::kMacSize;
    }
    UInt64 dataPos = item.GetDataPosition();
    inStream.Attach(archive.CreateLimitedStream(dataPos, packSize));
    authenticationPos = dataPos + packSize;
  }
  
  CMyComPtr<ICompressFilter> cryptoFilter;
  if (item.IsEncrypted())
  {
    if (wzAesMode)
    {
      CWzAesExtraField aesField;
      if (!item.CentralExtra.GetWzAesField(aesField))
        return S_OK;
      methodId = aesField.Method;
      if (!_wzAesDecoder)
      {
        _wzAesDecoderSpec = new NCrypto::NWzAes::CDecoder;
        _wzAesDecoder = _wzAesDecoderSpec;
      }
      cryptoFilter = _wzAesDecoder;
      Byte properties = aesField.Strength;
      RINOK(_wzAesDecoderSpec->SetDecoderProperties2(&properties, 1));
    }
    else if (pkAesMode)
    {
      if (!_pkAesDecoder)
      {
        _pkAesDecoderSpec = new NCrypto::NZipStrong::CDecoder;
        _pkAesDecoder = _pkAesDecoderSpec;
      }
      cryptoFilter = _pkAesDecoder;
    }
    else
    {
      if (!_zipCryptoDecoder)
      {
        _zipCryptoDecoderSpec = new NCrypto::NZip::CDecoder;
        _zipCryptoDecoder = _zipCryptoDecoderSpec;
      }
      cryptoFilter = _zipCryptoDecoder;
    }
    CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
    RINOK(cryptoFilter.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword));
//.........这里部分代码省略.........
开发者ID:Bernieboy,项目名称:nds4ios,代码行数:101,代码来源:ZipHandler.cpp

示例2: Decode

HRESULT CZipDecoder::Decode(
    CInArchive &archive, const CItemEx &item,
    ISequentialOutStream *realOutStream,
    IArchiveExtractCallback *_extractCallback,
    quint32 numThreads, qint32 &res)
{
    RefPtr<IArchiveExtractCallback> extractCallback(_extractCallback);

    res = NArchive::NExtract::NOperationResult::kDataError;
    CInStreamReleaser inStreamReleaser;

    bool needCRC = true;
    bool aesMode = false;
#ifdef ZIP_STRONG_SUPORT
    bool pkAesMode = false;
#endif
    quint16 methodId = item.CompressionMethod;
    if (item.IsEncrypted()) {
        if (item.IsStrongEncrypted()) {
#ifdef ZIP_STRONG_SUPORT
            CStrongCryptoField f;
            if (item.CentralExtra.GetStrongCryptoField(f)) {
                pkAesMode = true;
            }
            if (!pkAesMode)
#endif
            {
                res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
                return S_OK;
            }
        }
        if (methodId == NFileHeader::NCompressionMethod::kWzAES) {
            CWzAesExtraField aesField;
            if (item.CentralExtra.GetWzAesField(aesField)) {
                aesMode = true;
                needCRC = aesField.NeedCrc();
            }
        }
    }

    COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
    RefPtr<ISequentialOutStream> outStream = outStreamSpec;
    outStreamSpec->SetStream(realOutStream);
    outStreamSpec->Init(needCRC);

    quint64 authenticationPos;

    RefPtr<ISequentialInStream> inStream;
    {
        quint64 packSize = item.PackSize;
        if (aesMode) {
            if (packSize < NCrypto::NWzAES::kMacSize)
                return S_OK;
            packSize -= NCrypto::NWzAES::kMacSize;
        }
        quint64 dataPos = item.GetDataPosition();
        inStream = archive.CreateLimitedStream(dataPos, packSize);
        authenticationPos = dataPos + packSize;
    }

    RefPtr<ICompressFilter> cryptoFilter;
    if (item.IsEncrypted()) {
        if (aesMode) {
            CWzAesExtraField aesField;
            if (!item.CentralExtra.GetWzAesField(aesField))
                return S_OK;
            methodId = aesField.Method;
            if (!_aesDecoder) {
                _aesDecoderSpec = new NCrypto::NWzAES::CDecoder;
                _aesDecoder = _aesDecoderSpec;
            }
            cryptoFilter = _aesDecoder;
            quint8 properties = aesField.Strength;
            RINOK(_aesDecoderSpec->SetDecoderProperties2(&properties, 1));
        }
#ifdef ZIP_STRONG_SUPORT
        else if (pkAesMode) {
            if (!_zsDecoder) {
                _zsDecoderSpec = new NCrypto::NZipStrong::CDecoder;
                _zsDecoder = _zsDecoderSpec;
            }
            cryptoFilter = _zsDecoder;
        }
#endif
        else {
            if (!_zipCryptoDecoder) {
                _zipCryptoDecoderSpec = new NCrypto::NZip::CDecoder;
                _zipCryptoDecoder = _zipCryptoDecoderSpec;
            }
            cryptoFilter = _zipCryptoDecoder;
        }
        RefPtr<ICryptoSetPassword> cryptoSetPassword;
        RINOK(cryptoFilter.QueryInterface(&cryptoSetPassword));

        if (!getTextPassword)
            extractCallback.QueryInterface(&getTextPassword);

        if (getTextPassword) {
            QString password;
            RINOK(getTextPassword->CryptoGetTextPassword(&password));
//.........这里部分代码省略.........
开发者ID:bks,项目名称:qz7,代码行数:101,代码来源:ZipHandler.cpp


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