如何利用windows的API函数进行字符串的加解密?急用!(100分)

  • 主题发起人 主题发起人 aerobull
  • 开始时间 开始时间
A

aerobull

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,<br>用windows自带的函数,行不行?<br>给个delphi的例子,我不会C。
 
给你一个 vb 的例子,你把它翻译成delphi就行了,我用过的,保证没问题。<br>Public Function 数字加密(a As Long) As Long<br>Dim E As Integer<br>Dim C As Integer<br>Dim P As Integer<br>E = 1021<br>C = 1<br>P = 257<br>L1:<br>If (E = 0) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; 数字加密 = C<br>&nbsp; &nbsp;Else<br>L2:<br>&nbsp; &nbsp; &nbsp; If (E Mod 2 = 0) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;E = E / 2<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a = (a * a) Mod P<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GoTo L2<br>&nbsp; &nbsp; &nbsp; &nbsp; Else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;E = E - 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;C = (C * a) Mod P<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GoTo L1<br>&nbsp; &nbsp; &nbsp; &nbsp;End If<br>End If<br>End Function<br><br>Public Function 数字解密(a As Long) As Long<br>Dim D As Integer<br>Dim C As Integer<br>Dim P As Integer<br>D = 853<br>C = 1<br>P = 257<br>L1:<br>If (D = 0) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; 数字解密 = C<br>&nbsp; &nbsp; Else<br>L2:<br>&nbsp; &nbsp; &nbsp; &nbsp; If (D Mod 2 = 0) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; D = D / 2<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a = (a * a) Mod P<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GoTo L2<br>&nbsp; &nbsp; &nbsp; &nbsp; Else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; D = D - 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C = (C * a) Mod P<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GoTo L1<br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br>End If<br>End Function<br>
 
要用windows自带的加解密函数。
 
非要用windows自带的加解密函数?它很好吗???<br>
 
Microsoft CryptoAPI<br>是Microsoft公司在Windows 9x/NT平台上推出的安全加密应用体系和服务。
 
有必要吗?为什么一定要用windows自带的加解密函数???!!!自己写一个不是更好?
 
我一定要用windows自带的加解密函数,<br>知道的请出手。
 
to AeroBull:<br>我手头有一篇这样的文章,有人用CryptoAPI来解说WPS2000 的加密原理的,<br>如果要请EMail给我(Dxhsir@263.net)
 
我也需要,请发给我一份<br>qinghou@china.com
 
没人会么?<br>高手们请出手啊
 
大虾:<br>&nbsp; &nbsp;我也很感兴趣,帮帮忙发一份给我好嘛?<br>large_sh@163.com,万分感谢
 
API函数如下,请自己查阅相关API说明<br>//////////////////////////////////////////////////////<br>BOOL CRYPTFUNC CryptEncrypt(<br><br>&nbsp; &nbsp; HCRYPTKEY hKey, <br>&nbsp; &nbsp; HCRYPTHASH hHash, <br>&nbsp; &nbsp; BOOL Final, <br>&nbsp; &nbsp; DWORD dwFlags, <br>&nbsp; &nbsp; BYTE *pbData, <br>&nbsp; &nbsp; DWORD *pdwDataLen, <br>&nbsp; &nbsp; DWORD dwBufLen <br>&nbsp; &nbsp;);<br>//////////////////////////////////////////////////////<br>BOOL CRYPTFUNC CryptDecrypt(<br><br>&nbsp; &nbsp; HCRYPTKEY hKey, <br>&nbsp; &nbsp; HCRYPTHASH hHash, <br>&nbsp; &nbsp; BOOL Final, <br>&nbsp; &nbsp; DWORD dwFlags, <br>&nbsp; &nbsp; BYTE *pbData, <br>&nbsp; &nbsp; DWORD *pdwDataLen <br>&nbsp; &nbsp;); <br>/////////////////////////////////////////////////////<br>
 
急用就自己写一个,这种字符串变形的函数也不难写。<br>如果有win API的函数,我想你也不敢用,因为谁都知道解密。
 
JEDI就有声明好的加密M$的API!
 
算了我给你一个源码的DES算法得了
 
其实,不管什么文件都可以,比如: 可以把 ascii 码加 1,减 1 等等<br><br>很简单的
 
多人接受答案了。
 
后退
顶部