📄 des算法源程序.mht
字号:
<TR>
<TD bgColor=3Ddarkblue>
<TABLE cellSpacing=3D1 cellPadding=3D4 width=3D"100%" =
border=3D0>
<TBODY>
<TR class=3Dheader>
<TD width=3D152>=D7=F7=D5=DF:</TD>
<TD>
<TABLE class=3Dsmalltxt=20
style=3D"TABLE-LAYOUT: fixed; WORD-WRAP: break-word"=20
cellSpacing=3D0 cellPadding=3D0 width=3D"100%" =
border=3D0>
<TBODY>
<TR style=3D"COLOR: #ffffff">
<TD class=3Dbold>=B1=EA=CC=E2: <FONT=20
=
color=3Ddarkblue></FONT>DES=CB=E3=B7=A8=D4=B4=B3=CC=D0=F2</TD>
<TD noWrap align=3Dright width=3D150><A=20
style=3D"FONT-WEIGHT: normal; COLOR: #ffffff"=20
=
href=3D"http://25.20.176.12/bbs/redirect.php?fid=3D144&tid=3D17748&am=
p;goto=3Dnextoldset">=C9=CF=D2=BB=D6=F7=CC=E2</A>=20
| <A style=3D"FONT-WEIGHT: normal; COLOR: =
#ffffff"=20
=
href=3D"http://25.20.176.12/bbs/redirect.php?fid=3D144&tid=3D17748&am=
p;goto=3Dnextnewset">=CF=C2=D2=BB=D6=F7=CC=E2</A></TD></TR></TBODY></TABL=
E></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><A=20
name=3Dpid126363>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"100%" =
align=3Dcenter border=3D0>
<TBODY>
<TR>
<TD bgColor=3Ddarkblue>
<TABLE style=3D"TABLE-LAYOUT: fixed; WORD-WRAP: break-word"=20
cellSpacing=3D1 cellPadding=3D4 width=3D"100%" border=3D0>
<TBODY>
<TR bgColor=3D#e8f2ff>
<TD vAlign=3Dtop width=3D160>
<FIELDSET><LEGEND><A=20
=
href=3D"http://25.20.176.12/bbs/viewthread.php?tid=3D17748#endpid126363">=
<IMG=20
alt=3D=D7=AA=B5=BD=B5=DA1=CC=F9=C4=A9=CE=B2=20
=
src=3D"http://25.20.176.12/bbs/images/default/threadnext.gif"=20
border=3D0></A> <FONT title=3DPID=3D126363 =
color=3Dred>=C2=A5=D6=F7</FONT>=20
</LEGEND>
<TABLE style=3D"TABLE-LAYOUT: fixed" cellSpacing=3D0 =
cellPadding=3D0=20
width=3D"100%" border=3D0>
<TBODY>
<TR>
<TD>
<CENTER>
<H3>19820522</H3></CENTER><BR></TD></TR>
<TR bgColor=3D#e8f2cf>
<TD align=3Dmiddle><IMG=20
=
src=3D"http://25.20.176.12/bbs/customavatars/1991.gif"=20
border=3D0></TD></TR>
<TR>
<TD align=3Dmiddle><IMG=20
=
src=3D"http://25.20.176.12/bbs/images/default/star.gif"></TD></TR></TBODY=
></TABLE></FIELDSET>=20
<TABLE cellSpacing=3D0 cellPadding=3D3 width=3D"100%" =
border=3D0>
<TBODY>
<TR>
<TD class=3Drow><IMG height=3D11=20
=
src=3D"http://25.20.176.12/bbs/images/default/ball.gif"=20
width=3D10> =CD=B7=CF=CE: <FONT =
color=3Dred>=CA=A5=C6=EF=CA=BF</FONT></TD></TR>
<TR>
<TD class=3Drow><IMG height=3D11=20
=
src=3D"http://25.20.176.12/bbs/images/default/ball.gif"=20
width=3D10> =D0=D4=B1=F0: <FONT =
color=3Dred>=C4=D0<IMG title=3D=D0=D4=B1=F0=A3=BA=C4=D0=20
=
src=3D"http://25.20.176.12/bbs/images/default/male.gif">=20
</FONT><!--(=B7=A2=CC=F9:<font =
color=3D"red">65</font>=C6=AA)--></TD></TR>
<TR>
<TD class=3Drow title=3D"=BB=FD=B7=D6:11 =
=B7=D6<br>=B7=A2=CC=F9:65 =C6=AA"><IMG height=3D11=20
=
src=3D"http://25.20.176.12/bbs/images/default/ball.gif"=20
width=3D10> =BB=FD=B7=D6: <FONT =
color=3Dred>11</FONT>=B7=D6<!--(=B7=A2=CC=F9:<font =
color=3D"red">65</font>=C6=AA)--></TD></TR>
<TR>
<TD class=3Drow =
title=3D"=BE=AB=BB=AA=D6=B8=CA=FD:4 =B7=D6<br>=B7=A2=CC=F9:65 =
=C6=AA"><IMG height=3D11=20
=
src=3D"http://25.20.176.12/bbs/images/default/ball.gif"=20
width=3D10> =B7=A2=CC=F9: <FONT =
color=3Dred>65</FONT>=C6=AA</TD></TR>
<TR>
<TD class=3Drow=20
=
title=3D"=B2=C6=B8=BB:307+180<br>=CF=D6=BD=F0:307<br>=B4=E6=BF=EE:180<br>=
=B1=BC=CF=F2=D0=A1=BF=B5"><IMG=20
height=3D11=20
=
src=3D"http://25.20.176.12/bbs/images/default/ball.gif"=20
width=3D10> =B2=C6=B8=BB: <FONT =
color=3Dred>487</FONT> =BD=F0=B1=D2</TD></TR>
<TR>
<TD class=3Drow=20
title=3D"=B1=E0=BA=C5: =
<b>1991</b></br>=C0=B4=D7=D4:<br>=D7=A2=B2=E1: 2004-3-22"><IMG=20
height=3D11=20
=
src=3D"http://25.20.176.12/bbs/images/default/ball.gif"=20
width=3D10> =B1=E0=BA=C5: =A1=ED1991<IMG =
title=3D"=D7=B4=CC=AC =C0=EB=CF=DF"=20
=
src=3D"http://25.20.176.12/bbs/images/default/offline_user.gif"=20
align=3DabsMiddle> =
</TD></TR></TBODY></TABLE></TD>
<TD height=3D"100%">
<TABLE style=3D"TABLE-LAYOUT: fixed; WORD-WRAP: =
break-word"=20
height=3D"100%" cellSpacing=3D0 cellPadding=3D0 =
width=3D"100%"=20
border=3D0>
<TBODY>
<TR>
<TD vAlign=3Dtop><SPAN class=3Dbold><SPAN=20
class=3Dsmalltxt><FONT=20
=
color=3Ddarkblue></FONT>DES=CB=E3=B7=A8=D4=B4=B3=CC=D0=F2<BR><BR></SPAN><=
/SPAN><BR>The=20
DES library.<BR><BR>Please note that this =
library was=20
originally written to operate with<BR>eBones, a =
version=20
of Kerberos that had had encryption removed when =
it=20
left<BR>the USA and then put back =
in. As such=20
there are some routines that I will<BR>advise =
not using=20
but they are still in the library for historical =
reasons.<BR>For all calls that have an 'input' =
and=20
'output' variables, they can be =
the<BR>same.<BR><BR>This=20
library requires the inclusion of =
'des.h'.<BR><BR>All of=20
the encryption functions take what is called a=20
des_key_schedule as an =
<BR>argument. A=20
des_key_schedule is an expanded form of the des=20
key.<BR>A des_key is 8 bytes of odd parity, the =
type=20
used to hold the key is =
a<BR>des_cblock. A=20
des_cblock is an array of 8 bytes, often in this =
library<BR>description I will refer to input =
bytes when=20
the function specifies<BR>des_cblock's as input =
or=20
output, this just means that the variable =
should<BR>be a=20
multiple of 8 bytes.<BR><BR>The define =
DES_ENCRYPT is=20
passed to specify encryption, DES_DECRYPT =
to<BR>specify=20
decryption. The functions and global =
variable=20
are as follows:<BR><BR>int =
des_check_key;<BR> =20
DES keys are supposed to be =
odd=20
parity. If this variable is set =
to<BR> =20
a non-zero value, =
des_set_key()=20
will check that the key has odd<BR> =
=20
parity and is not one of the known weak =
DES=20
keys. By default this<BR> =
=20
variable is turned off;<BR> =
=20
<BR>void =
des_set_odd_parity(<BR>des_cblock *key=20
);<BR> This function =
takes a=20
DES key (8 bytes) and sets the parity to =
odd.<BR> =20
<BR>int=20
des_is_weak_key(<BR>des_cblock *key );<BR> =
=20
This function returns a non-zero =
value if=20
the DES key passed is a<BR> =
=20
weak, DES key. If it is a weak key, =
don't use=20
it, try a different<BR> =
=20
one. If you are using 'random' keys, =
the=20
chances of hitting a weak<BR> =
=20
key are 1/2^52 so it is probably not worth =
checking for=20
them.<BR> <BR>int=20
des_set_key(<BR>des_cblock =
*key,<BR>des_key_schedule=20
schedule);<BR> =
Des_set_key=20
converts an 8 byte DES key into a=20
des_key_schedule.<BR> =
A=20
des_key_schedule is an expanded form of the key =
which is=20
used to<BR> perform =
actual=20
encryption. It can be regenerated =
from the=20
DES key<BR> so it =
only needs=20
to be kept when encryption or decryption is=20
about<BR> to=20
occur. Don't save or pass around=20
des_key_schedule's since they<BR> =
=20
are CPU architecture dependent, DES keys =
are=20
not. If des_check_key<BR> =
=20
is non zero, zero is returned if the key =
has the=20
wrong parity or<BR> =
the key=20
is a weak key, else 1 is returned.<BR> =
=20
<BR>int =
des_key_sched(<BR>des_cblock=20
*key,<BR>des_key_schedule schedule);<BR> =
=20
An alternative name for=20
des_set_key().<BR><BR>int des_rw_mode; =
=20
/* =
defaults to=20
DES_PCBC_MODE */<BR> =
This=20
flag holds either DES_CBC_MODE or DES_PCBC_MODE=20
(default).<BR> This =
specifies=20
the function to use in the enc_read() and=20
enc_write()<BR> =20
functions.<BR><BR>void des_encrypt(<BR>unsigned =
long=20
*data,<BR>des_key_schedule ks,<BR>int =
enc);<BR> =20
This is the DES encryption =
function=20
that gets called by just about<BR> =
=20
every other DES routine in the=20
library. You should not use =
this<BR> =20
function except to =
implement=20
'modes' of DES. I say this because=20
the<BR> functions =
that call=20
this routine do the conversion from 'char *'=20
to<BR> long, and this =
needs=20
to be done to make sure 'non-aligned' =
memory<BR> =20
access do not =
occur. The=20
characters are loaded 'little endian',<BR> =
=20
have a look at my source code for =
more=20
details on how I use this<BR> =
=20
function.<BR> Data is =
a=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -