WPXEncryption.h Source File documentation

WPXEncryption.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/* libwpd
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2007 Jaroslav Fojtik (JaFojtik@seznam.cz)
11 * Copyright (C) 2007 Fridrich Strba (fridrich.strba@bluewin.ch)
12 *
13 * For minor contributions see the git repository.
14 *
15 * Alternatively, the contents of this file may be used under the terms
16 * of the GNU Lesser General Public License Version 2.1 or later
17 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18 * applicable instead of those above.
19 *
20 * For further information visit http://libwpd.sourceforge.net
21 */
22
23/* "This product is not manufactured, approved, or supported by
24 * Corel Corporation or Corel Corporation Limited."
25 */
26
27#ifndef WPXENCRYPTION_H
28#define WPXENCRYPTION_H
29
30#include <memory>
31
32#include <librevenge/librevenge.h>
33#include <libwpd/libwpd.h>
34
35 class WPXEncryption
36{
37public:
38 WPXEncryption(const char *password, const unsigned long encryptionStartOffset = 0);
39 ~WPXEncryption();
40
41 const unsigned char *readAndDecrypt(librevenge::RVNGInputStream *input, unsigned long numBytes, unsigned long &numBytesRead);
42 unsigned short getCheckSum() const;
43
44 void setEncryptionStartOffset(unsigned long encryptionStartOffset)
45 {
46 m_encryptionStartOffset = encryptionStartOffset;
47 }
48 unsigned long getEncryptionStartOffset() const
49 {
50 return m_encryptionStartOffset;
51 }
52
53 void setEncryptionMaskBase(unsigned char encryptionMaskBase)
54 {
55 m_encryptionMaskBase = encryptionMaskBase;
56 }
57 unsigned char getEncryptionMaskBase() const
58 {
59 return m_encryptionMaskBase;
60 }
61
62 const librevenge::RVNGString &getEncryptionPassword() const
63 {
64 return m_password;
65 }
66
67private:
68 std::unique_ptr<unsigned char[]> m_buffer;
69 librevenge::RVNGString m_password;
70 unsigned long m_encryptionStartOffset;
71 unsigned char m_encryptionMaskBase;
72 // Unimplemented to prevent compiler from creating crasher ones
73 WPXEncryption(const WPXEncryption &);
74 WPXEncryption &operator=(const WPXEncryption &);
75};
76
77#endif /* WPXENCRYPTION_H */
78/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPXEncryption::m_encryptionStartOffset
unsigned long m_encryptionStartOffset
Definition WPXEncryption.h:70
WPXEncryption::m_password
librevenge::RVNGString m_password
Definition WPXEncryption.h:69
WPXEncryption::getCheckSum
unsigned short getCheckSum() const
Definition WPXEncryption.cpp:52
WPXEncryption::operator=
WPXEncryption & operator=(const WPXEncryption &)
WPXEncryption::setEncryptionStartOffset
void setEncryptionStartOffset(unsigned long encryptionStartOffset)
Definition WPXEncryption.h:44
WPXEncryption::readAndDecrypt
const unsigned char * readAndDecrypt(librevenge::RVNGInputStream *input, unsigned long numBytes, unsigned long &numBytesRead)
Definition WPXEncryption.cpp:64
WPXEncryption::m_encryptionMaskBase
unsigned char m_encryptionMaskBase
Definition WPXEncryption.h:71
WPXEncryption::getEncryptionMaskBase
unsigned char getEncryptionMaskBase() const
Definition WPXEncryption.h:57
WPXEncryption::~WPXEncryption
~WPXEncryption()
Definition WPXEncryption.cpp:47
WPXEncryption::getEncryptionPassword
const librevenge::RVNGString & getEncryptionPassword() const
Definition WPXEncryption.h:62
WPXEncryption::m_buffer
std::unique_ptr< unsigned char[]> m_buffer
Definition WPXEncryption.h:68
WPXEncryption::setEncryptionMaskBase
void setEncryptionMaskBase(unsigned char encryptionMaskBase)
Definition WPXEncryption.h:53
WPXEncryption::getEncryptionStartOffset
unsigned long getEncryptionStartOffset() const
Definition WPXEncryption.h:48
WPXEncryption::WPXEncryption
WPXEncryption(const char *password, const unsigned long encryptionStartOffset=0)
Definition WPXEncryption.cpp:30
WPXEncryption::WPXEncryption
WPXEncryption(const WPXEncryption &)
libwpd.h