/* ---------------------------------------------------------------- * 功 能:SINGLE_DES解密 * 输入参数:uszKey 解密密钥 * uszSrc 解密前数据 * 输出参数:uszDest 解密后数据 * 返 回 值: * 作 者: * 日 期: * 调用说明: * 修改日志:修改日期 修改者 修改内容简述 * ---------------------------------------------------------------- */ void _DES(unsigned char *uszKey,unsigned char *uszSrc,unsigned char *uszDest) { char tmp[64]; expand0(uszKey,tmp); setkeystar((unsigned char*)tmp); discrypt0(uszSrc, uszDest); }
//_declspec(dllexport) void _DES(LPCSTR key, LPCSTR text, LPBYTE mtext) { char tmp[64]; int len; int i, j; char keytmp[10]; len = strlen(text); j = strlen(key); for(i = 0; i < 8; i++) { if( i < j ) keytmp[i] = key[i]; else keytmp[i] = 'x'; } keytmp[i] = '\0'; expand0(keytmp, tmp); setkeystar(tmp); i = len % 8; if( i != 0 ) { for(j = 0; j < i; j++) { mtext[j] = text[j] ^ (char)0xFF; } } for( ; i < len; i += 8 ) { discrypt0((LPBYTE)&text[i], (LPBYTE)&mtext[i]); } mtext[len] = '\0'; }
void _DES(unsigned char *key,unsigned char *text, unsigned char *mtext) { char tmp[64]; expand0(key, tmp); setkeystar(tmp); discrypt0(text, mtext); }
void ip(unsigned char *text,char *ll, char *rr) { int i; char buffer[64]; expand0(text,buffer); for (i=0;i<32;i++) ll[i]=buffer[ip_tab[i]-1]; for (i=0;i<32;i++) rr[i]=buffer[ip_tab[i+32]-1]; }
void _Des(unsigned char *key,unsigned char *text,unsigned char *mtext) { unsigned char tmp[64]; unsigned char keybuf[9]; unsigned char textbuf[9]; unsigned char mtextbuf[9]; memset(keybuf,0,9); memset(textbuf,0,9); memset(mtextbuf,0,9); aschex_to_bcdhex11((char*)key,16,(char*)keybuf); aschex_to_bcdhex11((char*)text,16,(char*)textbuf); expand0(keybuf,tmp); setkeystar(tmp); discrypt0(textbuf,mtextbuf); bcdhex_to_aschex11((char*)mtextbuf,8,(char*)mtext); }