其中的enigma.h:
void enigma1(ENIGMA t,char *buf,int len);
这个是基本的加密解密程序。
t是生成好的转轮加密机。
buf是需要加密解密的数据地址,len是字节数。
对明文运行一次,buf里就是密文。
对密文运行一次,buf里就是明文。
#define ROTORSZ 256
typedef char ENIGMA[3][ROTORSZ];//这看起来有点像ENIGMA的3个转轮,其实不是。
void frenz_encode(ENIGMA t,char *string,int len);//加密
void frenz_decode(ENIGMA t,char *string,int len);//解密
string就是上边的buf,名字起的不好。
这两个比ENIGMA1强度高一些,采用了明文字符影响下次转轮的步数,就是上文相关。
就是说,Cn=f(Mn,K,Mn-1);
【 在 ylh1969 的大作中提到: 】
: [upload=1][/upload]
: ENIGMA的电脑版,适合对byte流加密。
: 在明文空间就地加密,在密文空间就地解密,不需要另外的空间。
: ...................
#ifndef ENIGMA_H
#define ENIGMA_H
#define ROTORSZ 256
typedef char ENIGMA[3][ROTORSZ];
typedef struct {
ENIGMA t;
ENIGMA r;
INT4 crc;
} ENIGMA2;
#ifdef __cplusplus
extern "C" {
#endif
/* 改进的 ENIGMA 程序 */
void enigma1_init(ENIGMA t,char *key);
void enigma1(ENIGMA t,char *buf,int len);
//疯狂旋转的转轮机,完全屏蔽了列表特征,不存在周期性
void frenz_encode(ENIGMA t,char *string,int len);
void frenz_decode(ENIGMA t,char *string,int len);
/* 加密后扰码,用于配合多种加密手段 */
void enigma_rev(ENIGMA t,char *buf,int len);
/* 解扰后解密,用于解密 */
void rev_enigma(ENIGMA t,char *buf,int len);
/* 加强的ENIGMA程序,完全消除了密文与相似明文的对应关系 */
void enigma2_init(ENIGMA2 *ep,char *key); //初始化
void enigma2_encode(ENIGMA2 *ep,char *buf,int len); //加密
void enigma2_decode(ENIGMA2 *ep,char *buf,int len); //解密
#ifdef __cplusplus
}
#endif
#endif
--
修改:ylh1969 FROM 221.221.50.*
FROM 221.221.50.*