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


C++ CFX_ByteTextBuf::GetBuffer方法代码示例

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


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

示例1: SetColor

void CFX_PSRenderer::SetColor(FX_DWORD color, int alpha_flag, void* pIccTransform)
{
    if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
        pIccTransform = NULL;
    }
    FX_BOOL bCMYK = FALSE;
    if (pIccTransform) {
        ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
        color = FXGETFLAG_COLORTYPE(alpha_flag) ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
        FX_LPBYTE pColor = (FX_LPBYTE)&color;
        pIccModule->TranslateScanline(pIccTransform, pColor, pColor, 1);
        color = m_bCmykOutput ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
        bCMYK = m_bCmykOutput;
    } else {
        bCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
    }
    if (bCMYK != m_bCmykOutput || !m_bColorSet || m_LastColor != color) {
        CFX_ByteTextBuf buf;
        if (bCMYK) {
            buf << FXSYS_GetCValue(color) / 255.0 << FX_BSTRC(" ") << FXSYS_GetMValue(color) / 255.0 << FX_BSTRC(" ")
                << FXSYS_GetYValue(color) / 255.0 << FX_BSTRC(" ") << FXSYS_GetKValue(color) / 255.0 << FX_BSTRC(" k\n");
        } else {
            buf << FXARGB_R(color) / 255.0 << FX_BSTRC(" ") << FXARGB_G(color) / 255.0 << FX_BSTRC(" ")
                << FXARGB_B(color) / 255.0 << FX_BSTRC(" rg\n");
        }
        if (bCMYK == m_bCmykOutput) {
            m_bColorSet = TRUE;
            m_LastColor = color;
        }
        m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
    }
}
开发者ID:Gardenya,项目名称:pdfium,代码行数:32,代码来源:fx_ge_ps.cpp

示例2: SetGraphState

void CFX_PSRenderer::SetGraphState(const CFX_GraphStateData* pGraphState)
{
    CFX_ByteTextBuf buf;
    if (!m_bGraphStateSet || m_CurGraphState.m_LineCap != pGraphState->m_LineCap) {
        buf << pGraphState->m_LineCap << FX_BSTRC(" J\n");
    }
    if (!m_bGraphStateSet || m_CurGraphState.m_DashCount != pGraphState->m_DashCount ||
            FXSYS_memcmp32(m_CurGraphState.m_DashArray, pGraphState->m_DashArray, sizeof(FX_FLOAT)*m_CurGraphState.m_DashCount)) {
        buf << FX_BSTRC("[");
        for (int i = 0; i < pGraphState->m_DashCount; i ++) {
            buf << pGraphState->m_DashArray[i] << FX_BSTRC(" ");
        }
        buf << FX_BSTRC("]") << pGraphState->m_DashPhase << FX_BSTRC(" d\n");
    }
    if (!m_bGraphStateSet || m_CurGraphState.m_LineJoin != pGraphState->m_LineJoin) {
        buf << pGraphState->m_LineJoin << FX_BSTRC(" j\n");
    }
    if (!m_bGraphStateSet || m_CurGraphState.m_LineWidth != pGraphState->m_LineWidth) {
        buf << pGraphState->m_LineWidth << FX_BSTRC(" w\n");
    }
    if (!m_bGraphStateSet || m_CurGraphState.m_MiterLimit != pGraphState->m_MiterLimit) {
        buf << pGraphState->m_MiterLimit << FX_BSTRC(" M\n");
    }
    m_CurGraphState.Copy(*pGraphState);
    m_bGraphStateSet = TRUE;
    if (buf.GetSize()) {
        m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
    }
}
开发者ID:Gardenya,项目名称:pdfium,代码行数:29,代码来源:fx_ge_ps.cpp

示例3: SubmitForm

FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination,
                                      FX_BOOL bUrlEncoded) {
  if (sDestination.IsEmpty())
    return FALSE;

  if (!m_pDocument || !m_pInterForm)
    return FALSE;

  CPDFSDK_Environment* pEnv = m_pDocument->GetEnv();
  CFX_WideString wsPDFFilePath = m_pDocument->GetPath();
  CFDF_Document* pFDFDoc =
      m_pInterForm->ExportToFDF(wsPDFFilePath.AsStringC(), false);
  if (!pFDFDoc)
    return FALSE;

  CFX_ByteTextBuf FdfBuffer;
  FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer);
  delete pFDFDoc;
  if (!bRet)
    return FALSE;

  uint8_t* pBuffer = FdfBuffer.GetBuffer();
  FX_STRSIZE nBufSize = FdfBuffer.GetLength();

  if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize))
    return FALSE;

  pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str());

  if (bUrlEncoded)
    FX_Free(pBuffer);

  return TRUE;
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:34,代码来源:cpdfsdk_interform.cpp

示例4: DrawPath

FX_BOOL CFX_PSRenderer::DrawPath(const CFX_PathData* pPathData,
                                 const CFX_AffineMatrix* pObject2Device,
                                 const CFX_GraphStateData* pGraphState,
                                 FX_DWORD fill_color,
                                 FX_DWORD stroke_color,
                                 int fill_mode,
                                 int alpha_flag,
                                 void* pIccTransform
                                )
{
    StartRendering();
    int fill_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(fill_color);
    int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_STROKE(alpha_flag) : FXARGB_A(stroke_color);
    if (fill_alpha && fill_alpha < 255) {
        return FALSE;
    }
    if (stroke_alpha && stroke_alpha < 255) {
        return FALSE;
    }
    if (fill_alpha == 0 && stroke_alpha == 0) {
        return FALSE;
    }
    if (stroke_alpha) {
        SetGraphState(pGraphState);
        if (pObject2Device) {
            CFX_ByteTextBuf buf;
            buf << FX_BSTRC("mx Cm [") << pObject2Device->a << FX_BSTRC(" ") << pObject2Device->b << FX_BSTRC(" ") <<
                pObject2Device->c << FX_BSTRC(" ") << pObject2Device->d << FX_BSTRC(" ") << pObject2Device->e <<
                FX_BSTRC(" ") << pObject2Device->f << FX_BSTRC("]cm ");
            m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
        }
    }
    OutputPath(pPathData, stroke_alpha ? NULL : pObject2Device);
    if (fill_mode && fill_alpha) {
        SetColor(fill_color, alpha_flag, pIccTransform);
        if ((fill_mode & 3) == FXFILL_WINDING) {
            if (stroke_alpha) {
                OUTPUT_PS("q f Q ");
            } else {
                OUTPUT_PS("f");
            }
        } else if ((fill_mode & 3) == FXFILL_ALTERNATE) {
            if (stroke_alpha) {
                OUTPUT_PS("q F Q ");
            } else {
                OUTPUT_PS("F");
            }
        }
    }
    if (stroke_alpha) {
        SetColor(stroke_color, alpha_flag, pIccTransform);
        if (pObject2Device) {
            OUTPUT_PS("s sm");
        } else {
            OUTPUT_PS("s");
        }
    }
    OUTPUT_PS("\n");
    return TRUE;
}
开发者ID:Gardenya,项目名称:pdfium,代码行数:60,代码来源:fx_ge_ps.cpp

示例5: mailForm

FX_BOOL Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
	ASSERT(m_pDocument != NULL);

	if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;

	int iLength = params.size();

	FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE;
	CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L"";
	CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L"";
	CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L"";
	CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L"";
	CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L"";

	CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
	ASSERT(pInterForm != NULL);

	CFX_ByteTextBuf textBuf;
	if (!pInterForm->ExportFormToFDFTextBuf(textBuf))
		return FALSE;

	CJS_Context* pContext = (CJS_Context*)cc;
	ASSERT(pContext != NULL);
	CPDFDoc_Environment* pEnv = pContext->GetReaderApp();
	ASSERT(pEnv != NULL);
	CJS_Runtime* pRuntime = pContext->GetJSRuntime();
	ASSERT(pRuntime != NULL);

	pRuntime->BeginBlock();
	pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str());
	pRuntime->EndBlock();
	return TRUE;
}
开发者ID:mcanthony,项目名称:libpdf,代码行数:34,代码来源:Document.cpp

示例6: ReadHexString

CFX_ByteString CPDF_StreamParser::ReadHexString() {
  if (!PositionIsInBounds())
    return CFX_ByteString();

  CFX_ByteTextBuf buf;
  bool bFirst = true;
  int code = 0;
  while (PositionIsInBounds()) {
    int ch = m_pBuf[m_Pos++];

    if (ch == '>')
      break;

    if (!std::isxdigit(ch))
      continue;

    int val = FXSYS_toHexDigit(ch);
    if (bFirst) {
      code = val * 16;
    } else {
      code += val;
      buf.AppendByte((uint8_t)code);
    }
    bFirst = !bFirst;
  }
  if (!bFirst)
    buf.AppendChar((char)code);

  if (buf.GetLength() > MAX_STRING_LENGTH)
    return CFX_ByteString(buf.GetBuffer(), MAX_STRING_LENGTH);

  return buf.GetByteString();
}
开发者ID:hoanganhx86,项目名称:pdfium,代码行数:33,代码来源:fpdf_page_parser_old.cpp

示例7: WriteFile

FX_BOOL CFDF_Document::WriteFile(IFX_FileWrite *pFile) const
{
    CFX_ByteTextBuf buf;
    WriteBuf(buf);
    FX_BOOL bRet = pFile->WriteBlock(buf.GetBuffer(), buf.GetSize());
    if (bRet) {
        pFile->Flush();
    }
    return bRet;
}
开发者ID:MWisBest,项目名称:android_external_pdfium,代码行数:10,代码来源:fpdf_parser_fdf.cpp

示例8: ReadHexString

CFX_ByteString CPDF_StreamParser::ReadHexString()
{
    if (m_Size <= m_Pos) {
        return CFX_ByteString();
    }
    int ch = m_pBuf[m_Pos++];
    CFX_ByteTextBuf buf;
    FX_BOOL bFirst = TRUE;
    int code = 0;
    while (1) {
        if (ch == '>') {
            break;
        }
        if (ch >= '0' && ch <= '9') {
            if (bFirst) {
                code = (ch - '0') * 16;
            } else {
                code += ch - '0';
                buf.AppendChar((char)code);
            }
            bFirst = !bFirst;
        } else if (ch >= 'A' && ch <= 'F') {
            if (bFirst) {
                code = (ch - 'A' + 10) * 16;
            } else {
                code += ch - 'A' + 10;
                buf.AppendChar((char)code);
            }
            bFirst = !bFirst;
        } else if (ch >= 'a' && ch <= 'f') {
            if (bFirst) {
                code = (ch - 'a' + 10) * 16;
            } else {
                code += ch - 'a' + 10;
                buf.AppendChar((char)code);
            }
            bFirst = !bFirst;
        }
        if (m_Size <= m_Pos) {
            break;
        }
        ch = m_pBuf[m_Pos++];
    }
    if (!bFirst) {
        buf.AppendChar((char)code);
    }
    if (buf.GetLength() > MAX_STRING_LENGTH) {
        return CFX_ByteString(buf.GetBuffer(), MAX_STRING_LENGTH);
    }
    return buf.GetByteString();
}
开发者ID:azunite,项目名称:pdf_clone,代码行数:51,代码来源:fpdf_page_parser_old.cpp

示例9: OutputPath

void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device)
{
    int nPoints = pPathData->GetPointCount();
    CFX_ByteTextBuf buf;
    buf.EstimateSize(nPoints * 10);
    for (int i = 0; i < nPoints; i ++) {
        FX_BYTE flag = pPathData->GetFlag(i);
        FX_FLOAT x = pPathData->GetPointX(i);
        FX_FLOAT y = pPathData->GetPointY(i);
        if (pObject2Device) {
            pObject2Device->Transform(x, y);
        }
        buf << x << FX_BSTRC(" ") << y;
        switch (flag & FXPT_TYPE) {
            case FXPT_MOVETO:
                buf << FX_BSTRC(" m ");
                break;
            case FXPT_LINETO:
                if (flag & FXPT_CLOSEFIGURE) {
                    buf << FX_BSTRC(" l h ");
                } else {
                    buf << FX_BSTRC(" l ");
                }
                break;
            case FXPT_BEZIERTO: {
                    FX_FLOAT x1 = pPathData->GetPointX(i + 1);
                    FX_FLOAT x2 = pPathData->GetPointX(i + 2);
                    FX_FLOAT y1 = pPathData->GetPointY(i + 1);
                    FX_FLOAT y2 = pPathData->GetPointY(i + 2);
                    if (pObject2Device) {
                        pObject2Device->Transform(x1, y1);
                        pObject2Device->Transform(x2, y2);
                    }
                    buf << FX_BSTRC(" ") << x1 << FX_BSTRC(" ") << y1 << FX_BSTRC(" ") << x2 << FX_BSTRC(" ") << y2;
                    if (flag & FXPT_CLOSEFIGURE) {
                        buf << FX_BSTRC(" c h\n");
                    } else {
                        buf << FX_BSTRC(" c\n");
                    }
                    i += 2;
                    break;
                }
        }
    }
    m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
}
开发者ID:Gardenya,项目名称:pdfium,代码行数:46,代码来源:fx_ge_ps.cpp

示例10: SubmitFields

FX_BOOL CPDFSDK_InterForm::SubmitFields(
    const CFX_WideString& csDestination,
    const std::vector<CPDF_FormField*>& fields,
    bool bIncludeOrExclude,
    bool bUrlEncoded) {
  CPDFSDK_Environment* pEnv = m_pDocument->GetEnv();

  CFX_ByteTextBuf textBuf;
  ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf);

  uint8_t* pBuffer = textBuf.GetBuffer();
  FX_STRSIZE nBufSize = textBuf.GetLength();

  if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize))
    return FALSE;

  pEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str());
  return TRUE;
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:19,代码来源:cpdfsdk_interform.cpp

示例11: DrawText

FX_BOOL CFX_PSRenderer::DrawText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont,
                                 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device,
                                 FX_FLOAT font_size, FX_DWORD color,
                                 int alpha_flag, void* pIccTransform)
{
    StartRendering();
    int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
    if (alpha < 255) {
        return FALSE;
    }
    if ((pObject2Device->a == 0 && pObject2Device->b == 0) || (pObject2Device->c == 0 && pObject2Device->d == 0)) {
        return TRUE;
    }
    SetColor(color, alpha_flag, pIccTransform);
    CFX_ByteTextBuf buf;
    buf << FX_BSTRC("q[") << pObject2Device->a << FX_BSTRC(" ") << pObject2Device->b << FX_BSTRC(" ")
        << pObject2Device->c << FX_BSTRC(" ") << pObject2Device->d;
    buf << FX_BSTRC(" ") << pObject2Device->e << FX_BSTRC(" ") << pObject2Device->f << "]cm\n";
    if (pCache == NULL) {
        pCache = CFX_GEModule::Get()->GetFontCache();
    }
    CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
    FX_FONTCACHE_DEFINE(pCache, pFont);
    int last_fontnum = -1;
    for (int i = 0; i < nChars; i ++) {
        int ps_fontnum, ps_glyphindex;
        FindPSFontGlyph(pFaceCache, pFont, pCharPos[i], ps_fontnum, ps_glyphindex);
        if (last_fontnum != ps_fontnum) {
            buf << FX_BSTRC("/X") << ps_fontnum << FX_BSTRC(" Ff ") << font_size
                << FX_BSTRC(" Fs Sf ");
            last_fontnum = ps_fontnum;
        }
        buf << pCharPos[i].m_OriginX << FX_BSTRC(" ")
            << pCharPos[i].m_OriginY << FX_BSTRC(" m");
        CFX_ByteString hex;
        hex.Format("<%02X>", ps_glyphindex);
        buf << hex << FX_BSTRC("Tj\n");
    }
    buf << FX_BSTRC("Q\n");
    m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
    return TRUE;
}
开发者ID:Gardenya,项目名称:pdfium,代码行数:42,代码来源:fx_ge_ps.cpp

示例12: GenerateContent

void CPDF_PageContentGenerator::GenerateContent() {
  CFX_ByteTextBuf buf;
  CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict;
  for (int i = 0; i < m_pageObjects.GetSize(); ++i) {
    CPDF_PageObject* pPageObj = m_pageObjects[i];
    if (!pPageObj || !pPageObj->IsImage()) {
      continue;
    }
    ProcessImage(buf, pPageObj->AsImage());
  }
  CPDF_Object* pContent =
      pPageDict ? pPageDict->GetDirectObjectFor("Contents") : nullptr;
  if (pContent)
    pPageDict->RemoveFor("Contents");

  CPDF_Stream* pStream = new CPDF_Stream;
  pStream->SetData(buf.GetBuffer(), buf.GetLength());
  pPageDict->SetReferenceFor("Contents", m_pDocument,
                             m_pDocument->AddIndirectObject(pStream));
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:20,代码来源:cpdf_pagecontentgenerator.cpp

示例13: FDFToURLEncodedData

FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf,
                                               FX_STRSIZE& nBufSize) {
  CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize);
  if (!pFDF)
    return TRUE;

  CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictFor("FDF");
  if (!pMainDict)
    return FALSE;

  CPDF_Array* pFields = pMainDict->GetArrayFor("Fields");
  if (!pFields)
    return FALSE;

  CFX_ByteTextBuf fdfEncodedData;
  for (uint32_t i = 0; i < pFields->GetCount(); i++) {
    CPDF_Dictionary* pField = pFields->GetDictAt(i);
    if (!pField)
      continue;
    CFX_WideString name;
    name = pField->GetUnicodeTextFor("T");
    CFX_ByteString name_b = CFX_ByteString::FromUnicode(name);
    CFX_ByteString csBValue = pField->GetStringFor("V");
    CFX_WideString csWValue = PDF_DecodeText(csBValue);
    CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue);

    fdfEncodedData << name_b.GetBuffer(name_b.GetLength());
    name_b.ReleaseBuffer();
    fdfEncodedData << "=";
    fdfEncodedData << csValue_b.GetBuffer(csValue_b.GetLength());
    csValue_b.ReleaseBuffer();
    if (i != pFields->GetCount() - 1)
      fdfEncodedData << "&";
  }

  nBufSize = fdfEncodedData.GetLength();
  pBuf = FX_Alloc(uint8_t, nBufSize);
  FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize);
  return TRUE;
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:40,代码来源:cpdfsdk_interform.cpp

示例14: SetClip_PathStroke

void CFX_PSRenderer::SetClip_PathStroke(const CFX_PathData* pPathData,
                                        const CFX_AffineMatrix* pObject2Device,
                                        const CFX_GraphStateData* pGraphState
                                       )
{
    StartRendering();
    SetGraphState(pGraphState);
    if (pObject2Device) {
        CFX_ByteTextBuf buf;
        buf << FX_BSTRC("mx Cm [") << pObject2Device->a << FX_BSTRC(" ") << pObject2Device->b << FX_BSTRC(" ") <<
            pObject2Device->c << FX_BSTRC(" ") << pObject2Device->d << FX_BSTRC(" ") << pObject2Device->e <<
            FX_BSTRC(" ") << pObject2Device->f << FX_BSTRC("]cm ");
        m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
    }
    OutputPath(pPathData, NULL);
    CFX_FloatRect rect = pPathData->GetBoundingBox(pGraphState->m_LineWidth, pGraphState->m_MiterLimit);
    rect.Transform(pObject2Device);
    m_ClipBox.Intersect(rect.GetOutterRect());
    if (pObject2Device) {
        OUTPUT_PS("strokepath W n sm\n");
    } else {
        OUTPUT_PS("strokepath W n\n");
    }
}
开发者ID:Gardenya,项目名称:pdfium,代码行数:24,代码来源:fx_ge_ps.cpp

示例15: Revision6_Hash

void Revision6_Hash(const uint8_t* password,
                    uint32_t size,
                    const uint8_t* salt,
                    const uint8_t* vector,
                    uint8_t* hash) {
  int iBlockSize = 32;
  uint8_t sha[128];
  CRYPT_SHA256Start(sha);
  CRYPT_SHA256Update(sha, password, size);
  CRYPT_SHA256Update(sha, salt, 8);
  if (vector) {
    CRYPT_SHA256Update(sha, vector, 48);
  }
  uint8_t digest[32];
  CRYPT_SHA256Finish(sha, digest);
  CFX_ByteTextBuf buf;
  uint8_t* input = digest;
  uint8_t* key = input;
  uint8_t* iv = input + 16;
  uint8_t* E = buf.GetBuffer();
  int iBufLen = buf.GetLength();
  CFX_ByteTextBuf interDigest;
  int i = 0;
  uint8_t* aes = FX_Alloc(uint8_t, 2048);
  while (i < 64 || i < E[iBufLen - 1] + 32) {
    int iRoundSize = size + iBlockSize;
    if (vector) {
      iRoundSize += 48;
    }
    iBufLen = iRoundSize * 64;
    buf.EstimateSize(iBufLen);
    E = buf.GetBuffer();
    CFX_ByteTextBuf content;
    for (int j = 0; j < 64; ++j) {
      content.AppendBlock(password, size);
      content.AppendBlock(input, iBlockSize);
      if (vector) {
        content.AppendBlock(vector, 48);
      }
    }
    CRYPT_AESSetKey(aes, 16, key, 16, TRUE);
    CRYPT_AESSetIV(aes, iv);
    CRYPT_AESEncrypt(aes, E, content.GetBuffer(), iBufLen);
    int iHash = 0;
    switch (BigOrder64BitsMod3(E)) {
      case 0:
        iHash = 0;
        iBlockSize = 32;
        break;
      case 1:
        iHash = 1;
        iBlockSize = 48;
        break;
      default:
        iHash = 2;
        iBlockSize = 64;
        break;
    }
    interDigest.EstimateSize(iBlockSize);
    input = interDigest.GetBuffer();
    if (iHash == 0) {
      CRYPT_SHA256Generate(E, iBufLen, input);
    } else if (iHash == 1) {
      CRYPT_SHA384Generate(E, iBufLen, input);
    } else if (iHash == 2) {
      CRYPT_SHA512Generate(E, iBufLen, input);
    }
    key = input;
    iv = input + 16;
    ++i;
  }
  FX_Free(aes);
  if (hash) {
    FXSYS_memcpy(hash, input, 32);
  }
}
开发者ID:gradescope,项目名称:pdfium,代码行数:76,代码来源:cpdf_security_handler.cpp


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