Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_encryptor.cpp
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "core/fpdfapi/parser/cpdf_encryptor.h"
8
9#include <stdint.h>
10
11#include "core/fpdfapi/parser/cpdf_crypto_handler.h"
12#include "core/fxcrt/data_vector.h"
13#include "third_party/base/check.h"
14
16 : m_pHandler(pHandler), m_ObjNum(objnum) {
17 DCHECK(m_pHandler);
18}
19
21 pdfium::span<const uint8_t> src_data) const {
22 if (src_data.empty())
23 return DataVector<uint8_t>();
24
25 DataVector<uint8_t> result;
26 size_t buf_size = m_pHandler->EncryptGetSize(src_data);
27 result.resize(buf_size);
28 m_pHandler->EncryptContent(m_ObjNum, 0, src_data, result.data(),
29 buf_size); // Updates |buf_size| with actual.
30 result.resize(buf_size);
31 return result;
32}
33
34CPDF_Encryptor::~CPDF_Encryptor() = default;
CPDF_Encryptor(const CPDF_CryptoHandler *pHandler, int objnum)
DataVector< uint8_t > Encrypt(pdfium::span< const uint8_t > src_data) const