00001 /* Abiword 00002 * Copyright (C) 2002 Christian Biesinger <cbiesinger@web.de> 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 * 02110-1301 USA. 00018 */ 00019 00023 #include <string.h> // for memcpy 00024 #include "ut_types.h" 00025 #include "ut_string_class.h" 00026 00028 class SDWCryptor { 00029 public: 00031 enum { maxPWLen = 16 }; 00039 SDWCryptor(UT_uint32 aDate = 0, UT_uint32 aTime = 0, const UT_uint8* aFilePass = NULL); 00040 ~SDWCryptor(); 00042 void SetDateTime(UT_uint32 aDate, UT_uint32 aTime) { mDate = aDate; mTime = aTime; } 00051 bool SetPassword(const char* aPassword); 00052 00059 void Decrypt(const char* aEncrypted, char* aBuffer, UT_uint32 aLen = 0) const; 00060 00062 void Encrypt(const char* aDecrypted, char* aBuffer, UT_uint32 aLen = 0) const { Decrypt(aDecrypted, aBuffer, aLen); } 00063 protected: 00064 UT_uint32 mDate; 00065 UT_uint32 mTime; 00066 char mPassword[maxPWLen]; 00067 UT_uint8 mFilePass[maxPWLen]; 00068 }; 00069 00070