📄 encryption.mht
字号:
Oct=20
=
'07</B> </FONT></TD></TR></TBODY></TABLE></TD></TR>
<TR id=3D2270123_h1 style=3D"DISPLAY: none">
<TD width=3D"100%">
<TABLE cellSpacing=3D0 cellPadding=3D0 =
width=3D"100%"=20
border=3D0>
<TBODY>
<TR>
<TD><IMG=20
=
src=3D"http://www.codeproject.com/script/images/news_blank.gif"=20
align=3DabsMiddle> </TD>
<TD width=3D"100%" bgColor=3D#d5eaff>
<TABLE cellSpacing=3D5 cellPadding=3D0 =
width=3D"100%"=20
border=3D0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=3D0 cellPadding=3D0 =
width=3D"100%"=20
border=3D0>
<TBODY>
<TR>
<TD colSpan=3D2><FONT =
class=3Dmessagecontent>The=20
origin of the key and more... can be =
found on=20
external article (Year 2001):<BR>PHD =
Computer=20
Consultants Ltd. Setting the RC4 key in =
Windows=20
CryptoAPI <BR>Article Copyright =A9 =
2001,2003 PHD=20
Computer Consultants=20
=
Ltd.<BR>http://www.phdcc.com/cryptorc4.htm<BR><BR>This=20
old article is base on Microsoft =
Q228786:<BR>How=20
to export and import plain text session =
keys by=20
using CryptoAPI<BR>Article Copyright =A9 =
????=20
=
Microsoft.<BR>http://support.microsoft.com/?scid=3Dkb%3Ben-us%3B228786&am=
p;x=3D24&y=3D10<BR><BR><BR><BR>
<DIV=20
=
class=3DForumSig>...</DIV><BR> </FONT></TD></TR>
<TR vAlign=3Dtop>
<TD class=3Dmessagetitle>[<A=20
title=3D"Reply to this current thread"=20
=
href=3D"http://www.codeproject.com/script/comments/user_reply.asp?main=3D=
/cpp/EncryptionCryptoAPI.asp&df=3D100&forumid=3D214339&select=
=3D2270123">Reply</A>=20
| <A=20
title=3D"Email a reply to the author of =
this message"=20
=
href=3D"http://www.codeproject.com/script/comments/user_mail.asp?main=3D/=
cpp/EncryptionCryptoAPI.asp&df=3D100&forumid=3D214339&select=3D=
2270123">Email</A>=20
| <A=20
title=3D"View only messages within this =
thread"=20
=
href=3D"http://www.codeproject.com/cpp/EncryptionCryptoAPI.asp?df=3D100&a=
mp;tid=3D2270123&forumid=3D214339&select=3D2270123#xx2270123xx">V=
iew=20
Thread</A> | <A=20
title=3D"Get the URL for this message"=20
=
href=3D"http://www.codeproject.com/cpp/EncryptionCryptoAPI.asp?msg=3D2270=
123#xx2270123xx">PermaLink</A>=20
| <A title=3D"Go to Thread Start"=20
=
href=3D"http://www.codeproject.com/cpp/EncryptionCryptoAPI.asp?msg=3D2270=
123#xx2270123xx">Go=20
to Thread Start</A>]</TD>
<TD class=3Dmessagetitle align=3Dright>
<SCRIPT =
language=3DJavascript>MsgVoteForm(189262,2270123);</SCRIPT>
=
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></T=
ABLE></TD></TR>
<TR>
<TD><IMG height=3D5=20
=
src=3D"http://www.codeproject.com/script/images/t.gif"=20
width=3D1 border=3D0></TD></TR>
<TR height=3D1>
<TD bgColor=3D#ff9900><IMG height=3D1=20
=
src=3D"http://www.codeproject.com/script/images/t.gif"=20
width=3D1></TD></TR>
<TR id=3D1452845_h0 bgColor=3D#fef9e7>
<TD width=3D"100%">
<TABLE cellSpacing=3D0 cellPadding=3D0 =
width=3D"100%"=20
border=3D0>
<TBODY>
<TR>
<TD bgColor=3Dwhite><A =
name=3Dxx1452845xx></A><IMG=20
=
src=3D"http://www.codeproject.com/script/images/news_question.gif"=20
align=3DabsMiddle> </TD>
<TD class=3Dmessagetitle =
width=3D"100%"><A=20
class=3Dmessagetitle id=3DDynMessLink=20
=
href=3D"http://www.codeproject.com/cpp/EncryptionCryptoAPI.asp?df=3D100&a=
mp;forumid=3D214339&select=3D1452845#xx1452845xx"=20
name=3D1452845><B>the key in =
key.h</B></A></TD>
<TD vAlign=3Dbottom noWrap><A=20
=
href=3D"http://www.codeproject.com/script/profile/whos_who.asp?id=3D35787=
3"><IMG=20
title=3D"Click for User Profile" =
height=3D15=20
=
src=3D"http://www.codeproject.com/script/images/userinfo.gif"=20
width=3D14 border=3D0></A> </TD>
<TD noWrap width=3D140><FONT=20
class=3Dmessagetitle><B>Ray=20
Cheng</B> </FONT></TD>
<TD style=3D"WIDTH: 9em" noWrap =
align=3Dright=20
width=3D120><FONT =
class=3Dmessagetitle><B>3:07 18=20
Apr=20
=
'06</B> </FONT></TD></TR></TBODY></TABLE></TD></TR>
<TR id=3D1452845_h1 style=3D"DISPLAY: none">
<TD width=3D"100%">
<TABLE cellSpacing=3D0 cellPadding=3D0 =
width=3D"100%"=20
border=3D0>
<TBODY>
<TR>
<TD><IMG=20
=
src=3D"http://www.codeproject.com/script/images/news_blank.gif"=20
align=3DabsMiddle> </TD>
<TD width=3D"100%" bgColor=3D#d5eaff>
<TABLE cellSpacing=3D5 cellPadding=3D0 =
width=3D"100%"=20
border=3D0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=3D0 cellPadding=3D0 =
width=3D"100%"=20
border=3D0>
<TBODY>
<TR>
<TD colSpan=3D2><FONT =
class=3Dmessagecontent>Hi=20
Jessn,<BR><BR>I was coding based on your =
codes,=20
and I run into the problem of =
imports/exports.=20
This is what I did.<BR><BR>I see that in =
the=20
absence of key.txt, you generate a =
session key=20
based on a hard-coded key in key.h. So I =
mimick=20
that by doing<BR><BR>HCRYPTKEY =
pkey;<BR>int res=20
=3D CryptGenKey(m_prov, CALG_RC4,=20
CRYPT_EXPORTABLE, &pkey);<BR>res =3D =
CryptExportKey(pkey, 0, PUBLICKEYBLOB , =
0, NULL,=20
&size); // to get the =
size.<BR><BR>It=20
miserably fails, saying that a bad key =
is=20
provided.<BR><BR>Then I tried =
<BR>HCRYPTKEY=20
pkey;<BR>int res =3D CryptGenKey(m_prov, =
AT_KEYEXCHANGE, CRYPT_EXPORTABLE,=20
&pkey);<BR>res =3D =
CryptExportKey(pkey, 0,=20
PUBLICKEYBLOB , 0, NULL, &size); // =
to get=20
the size.<BR><BR>And I get some hundred =
bytes=20
for the key. Then I replaced the key in =
key.h=20
with these bytes. It seems to be running =
perfectly okay on 1 PC. But then when I =
generate=20
the session key on one pc, export it =
into a=20
file, import it on another PC, and try =
to=20
decrypt whatever that's been encrypted, =
I get a=20
Bad Data error (NTE_BAD_DATA). =
<BR><BR>This=20
problem doesn't occur when I use your =
key. What=20
mistakes have I made in generating this =
key? How=20
did you generate that key? <IMG=20
=
src=3D"http://www.codeproject.com/script/images/smiley_confused.gif"=20
align=3DabsMiddle><BR><BR><BR><BR>-- =
modified at=20
3:48 Tuesday 18th April,=20
2006<BR> </FONT></TD></TR>
<TR vAlign=3Dtop>
<TD class=3Dmessagetitle>[<A=20
title=3D"Reply to this current thread"=20
=
href=3D"http://www.codeproject.com/script/comments/user_reply.asp?main=3D=
/cpp/EncryptionCryptoAPI.asp&df=3D100&forumid=3D214339&select=
=3D1452845">Reply</A>=20
| <A=20
title=3D"Email a reply to the author of =
this message"=20
=
href=3D"http://www.codeproject.com/script/comments/user_mail.asp?main=3D/=
cpp/EncryptionCryptoAPI.asp&df=3D100&forumid=3D214339&select=3D=
1452845">Email</A>=20
| <A=20
title=3D"View only messages within this =
thread"=20
=
href=3D"http://www.codeproject.com/cpp/EncryptionCryptoAPI.asp?df=3D100&a=
mp;tid=3D1452845&forumid=3D214339&select=3D1452845#xx1452845xx">V=
iew=20
Thread</A> | <A=20
title=3D"Get the URL for this message"=20
=
href=3D"http://www.codeproject.com/cpp/EncryptionCryptoAPI.asp?msg=3D1452=
845#xx1452845xx">PermaLink</A>=20
| <A title=3D"Go to Thread Start"=20
=
href=3D"http://www.codeproject.com/cpp/EncryptionCryptoAPI.asp?msg=3D1452=
845#xx1452845xx">Go=20
to Thread Start</A>]</TD>
<TD class=3Dmessagetitle align=3Dright>
<SCRIPT =
language=3DJavascript>MsgVoteForm(357873,1452845);</SCRIPT>
=
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></T=
ABLE></TD></TR>
<TR>
<TD><IMG height=3D6=20
=
src=3D"http://www.codeproject.com/script/images/t.gif"=20
width=3D1 border=3D0></TD></TR>
<TR id=3D1453099_h0 bgColor=3D#fef9e7>
<TD width=3D"100%">
<TABLE cellSpacing=3D0 cellPadding=3D0 =
width=3D"100%"=20
border=3D0>
<TBODY>
<TR>
<TD bgColor=3Dwhite><A =
name=3Dxx1453099xx></A><IMG=20
height=3D1=20
=
src=3D"http://www.codeproject.com/script/images/ind.gif"=20
width=3D18><IMG=20
=
src=3D"http://www.codeproject.com/script/images/news_answer.gif"=20
align=3DabsMiddle> </TD>
<TD class=3Dmessagetitle =
width=3D"100%"><A=20
class=3Dmessagetitle id=3DDynMessLink=20
=
href=3D"http://www.codeproject.com/cpp/EncryptionCryptoAPI.asp?df=3D100&a=
mp;forumid=3D214339&select=3D1453099#xx1453099xx"=20
name=3D1453099>Re: the key in =
key.h</A></TD>
<TD vAlign=3Dbottom noWrap><A=20
=
href=3D"http://www.codeproject.com/script/profile/whos_who.asp?id=3D15469=
14"><IMG=20
title=3D"Click for User Profile" =
height=3D15=20
=
src=3D"http://www.codeproject.com/script/images/userinfo.gif"=20
width=3D14 border=3D0></A> </TD>
<TD noWrap width=3D140><FONT=20
=
class=3Dmessagetitle>Jessn </FONT></TD>
<TD style=3D"WIDTH: 9em" noWrap =
align=3Dright=20
width=3D120><FONT =
class=3Dmessagetitle>6:56 18 Apr=20
=
'06 </FONT></TD><
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -