| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 606 人关注过本帖
标题:这段代码的涵义
只看楼主 加入收藏
jiangyaokai
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-9-11
收藏
 问题点数:0 回复次数:1 
这段代码的涵义
Private Sub mnuEncryptBinary_Click()
Dim EncStr As String
Dim EncKey As String, TempEncKey As String
Dim EncLen As Integer
Dim EncPos As Integer
Dim EncKeyPos As Integer
Dim tempChar As String
Dim TA As Integer, TB As Integer, TC As Integer

UndoText(frm) = ChildForms(frm).Text1.Text
JustChanged = True

TempEncKey = InputBox("Enter the encryption key.  This key will be vital for decrypting this text later.", "Encrypt")
If TempEncKey = "" Then Exit Sub
EncStr = ""
EncPos = 1
EncKeyPos = 1

For x = 1 To Len(TempEncKey)
EncKey = EncKey & Asc(Mid$(TempEncKey, x, 1))
Next

EncLen = Len(EncKey)

For x = 1 To Len(ChildForms(frm).Text1.Text)
TB = Asc(Mid$(EncKey, EncKeyPos, 1))
EncKeyPos = EncKeyPos + 1
If EncKeyPos > EncLen Then EncKeyPos = 1
TA = Asc(Mid$(ChildForms(frm).Text1.Text, x, 1))
TC = TB Xor TA
tempChar = GetBinary(TC)
EncStr = EncStr & tempChar
Next
ChildForms(frm).Text1.Text = EncStr
End Sub

Private Sub mnuDecryptBinary_Click()
Dim EncStr As String
Dim EncKey As String, TempEncKey As String
Dim EncLen As Integer
Dim EncPos As Integer
Dim EncKeyPos As Integer
Dim tempChar As String
Dim TA As Integer, TB As Integer, TC As Integer

UndoText(frm) = ChildForms(frm).Text1.Text
JustChanged = True

TempEncKey = InputBox("Enter the decryption key.  This is the key that was typed for encryption.", "Decrypt")
If TempEncKey = "" Then Exit Sub
EncStr = ""
EncPos = 1
EncKeyPos = 1
For x = 1 To Len(TempEncKey)
EncKey = EncKey & Asc(Mid$(TempEncKey, x, 1))
Next
EncLen = Len(EncKey)

For x = 1 To Len(ChildForms(frm).Text1.Text) Step 8
TB = Asc(Mid$(EncKey, EncKeyPos, 1))
EncKeyPos = EncKeyPos + 1
If EncKeyPos > EncLen Then EncKeyPos = 1
tempChar = Mid$(ChildForms(frm).Text1.Text, x, 8)
TA = BintoDec(tempChar)
TC = TB Xor TA
EncStr = EncStr & Chr$(TC)
Next
ChildForms(frm).Text1.Text = EncStr
End Sub
研究了很长时间,不知道有没有哪位可以加一下注释或者解释一下数据流程
搜索更多相关主题的帖子: 涵义 代码 
2005-09-11 02:21
leon2
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:731
专家分:0
注 册:2005-3-18
收藏
得分:0 
是一段编码和解码的算法,通过指定的密码的 ASCII 值,进行异或(Xor)来加密和解密文本。这段代码我在 http://www.zjol.com.cn/vbbible 见过,是在一个 VB 编的多文档记事本程序里的。
2005-09-11 17:58
快速回复:这段代码的涵义
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029113 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved