des.h

来自「DES算法原理及实现,实现了3DES和DES的程序过程」· C头文件 代码 · 共 69 行

H
69
字号
/*
*	 Header file for class of representing des algorithm
*    Copyright (C) 2007  Stone
*
*    This program is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*
*    Contact me by stoneyrh@163.com 
*
*/
#ifndef DES_H
#define DES_H

#include "deskey.h"

#define DEFAULT_KEY 0XEB0AA5155328513BL

class des
{
public:
	/*
	* use DEFAULT_KEY as the key
	*/
	des(void);
	/*
	* spedify a key
	*/
	des(unsigned _int64 key);
	~des(void);

	/*
	* set the key to another key
	*/
	void setkey(unsigned _int64 key);

	/*
	* encypt the data pointed by dpointer
	* if succeed, return true, otherwise false
	* count specifies how many unsigned _int64 
	* contained in the memory pointed by dpointer
	* when return true, dpointer also point to the 
	* encrypted data
	*/
	bool encrypt(unsigned _int64* dpointer,unsigned _int64 count);
	/*
	* decypt the data pointed by dpointer
	* if succeed, return true, otherwise false
	* count specifies how many unsigned _int64 
	* contained in the memory pointed by dpointer
	* when return true, dpointer also point to the 
	* decrypted data
	*/
	bool decrypt(unsigned _int64* dpointer,unsigned _int64 count);

private:
	deskey dkey;
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?