sa22
|
分享:
▼
x0
|
[Basic][精华] 请问密码解密的程式该怎写?(加密已写出来)
Dim myFile, myID, myPw, addpw(), cc As String, adPw addpw = Array("*", "(", ")", "_", "+", "c", "d", "e", &q .. 访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容
[ 此文章被codeboy在2005-06-05 13:06重新编辑 ]
|
|
x1
[楼 主]
From:台湾 | Posted:2005-01-24 22:17 |
|
|
panasonic732
|
分享:
▲
▼
晚点在帮你一个完整的答覆 不过阿基础的编密 应该是把 基本码(如ASC)+偏移量 在经由Mid拆解数字去取 Array阵列质 不过偏移量还是得纪录在解密的程式理以供解密 或是包含在加密后的文字码里 我有练习过编码加密 附件便是噜 参考看看^^" 输入 books 输出 **hbieieiaii#f*** 复制程式
Sub main()
Dim Data1 As String, N1 As String, X1 As String, N2 As String
Dim I As Long, S As Long, D As Long
Open App.Path & "\Input.txt" For Input As #1 '开输入文字档
Open App.Path & "\Output.txt" For Output As #2 '开输出文字档
Input #1, Data1 '读输入文字档到 Data1变数中
Data1 = UCase(Data1) '将变数中的英文强制转换为大写
R = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j") '编码的阵列 如R(0)=a
I = 1
Do
N1 = Data1: X1 = X1 & Mid(Data1, I, 1)
If N1 = X1 Then: S = I: Exit Do
I = I + 1
Loop Until S < 0 '这个回圈用Len代替即可...目的在测出字串的字数
D = S '将字串长度丢给D
For I = 1 To S '此回圈在做排除空白键的动作 空白键ASCII 为32
If Asc(Mid(Data1, I, 1)) = 32 Then
D = D - 1
End If
Next I
For I = 1 To S '开始在做加密的动作
If Asc(Mid(Data1, I, 1)) = 32 Then '判断是否为空白键 是的话则输入空白键
N2 = N2 & " "
Else
N2 = N2 & Asc(Mid(Data1, I, 1)) + D Mod 10
'撷取字串转换ASCII+偏移量(字串长度mod10)
End If
Next I
N1 = "": X1 = "": I = 1: Data = "**" '该题编码规则开头为两个**
Do
N1 = N2: X1 = X1 & Mid(N2, I, 1) '这个部分用VB的F8单部执行就懂了
If Asc(Mid(N2, I, 1)) = 32 Then '如字串中的空白键输出为*
Data = Data & "*"
Else
Data = Data & R(Val(Mid(N2, I, 1))) '转化R阵列的值
End If
If N1 = X1 Then: Exit Do '长度相同跳出回圈
I = I + 1
Loop Until S < 0
I = 1: X1 = "": N2 = ""
Do
N1 = D: X1 = X1 & Mid(D, I, 1) '这个部分用VB的F8单部执行就懂了
N2 = N2 & R(Mid(D, I, 1)) '将偏移量转化为R阵列的值
If N1 = X1 Then: S = I: Exit Do '长度相同跳出回圈
I = I + 1
Loop Until S < 0
Data = Data & "#" & N2 & "***" '编码的资料尾端加上#偏移量###
Print #2, Data
Close #1
Close #2
End Sub
程式码有点略长,因为小弟在撰写程式,有个坏习惯 常常忘了有代替的函数可以用... 所以常常把程式写的又臭又长...
[ 此文章被panasonic732在2005-01-28 09:23重新编辑 ]
此文章被评分,最近评分记录财富:10 (by codeboy) | 理由: 好范例~^^ | |
|
|
|
忧虑不断,心未宁静
绵绵春雨,花失娇艳
凋零磨灭,事情难回
得意失意,不再回想
放弃它吧,唯有如此
|
x0
[3 楼]
From:台湾中华电信
| Posted:2005-01-25 01:13 |
|
|
sa22
|
分享:
▲
▼
在看到你回覆的同时,我也写到一半有个问题 QQ" 我将MOD去掉,取而代之的是用一个myInput来求出该字串所代表的数字再用addPW加密 复制程式
Private Sub CommandButton1_Click()
Dim myFile, myID, myPw, addPw(), cc As Integer, adPw, secPw(), myInputLen, N1, N2, N3, N4, myinput(), mySec
addPw = Array("0*", "1(", "1)", "1_", "1+", "1c", "1d", "1e", "1f", "1|", "1_", "1=", "1\", "1<", "1>", "1/", "1J", "1P", "1Q", "1R", "1W", "1X", "1Y", "1Z", "1S", "1T", "1U", "1V", "1a", "1b", "1h", "1i", "1j", "1k", "1l", "1~", "1!", "1@", "1#", "1$", "1%", "1^", "0*", "0(", "0)", "0_", "0+", "0c", "0d", "0e", "0f", "0|", "0_", "0=", "0\", "0<", "0>", "0/", "0J", "0P", "0Q", "0R", "0W", "0X", "0Y", "0Z", "0S", "0T", "0U", "0V", "0a", "0b", "0h", "0i", "0j", "0k", "0l", "0~", "0!", "0@", "0#", "0$", "0%", "0^")
myinput = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
'求阵列变数的数量
mySec = Second(Now())
a = UBound(myinput())
b = UBound(addPw())
N1 = Range("a1").Value
myInputLen = Len(N1)
For i = 1 To myInputLen
N2 = Mid(N1, i, 1): j = 0
Do Until j = b
If N2 = myinput(j) Then N3 = N3 & Format(j, "00"): N4 = N4 & addPw((j + Right(mySec, 1))): Exit Do Else j = j + 1
Loop
Range("a2").Value = N3
Next
Range("a2").Value = N3
Range("a3").Value = N4 & addPw(Right(mySec, 1))
End Sub
Private Sub CommandButton2_Click()
Dim myFile, myID, myPw, addPw(), cc As Integer, adPw, secPw(), myInputLen, N1, N2, N3, N4, myinput(), mySec
addPw = Array("0*", "1(", "1)", "1_", "1+", "1c", "1d", "1e", "1f", "1|", "1_", "1=", "1\", "1<", "1>", "1/", "1J", "1P", "1Q", "1R", "1W", "1X", "1Y", "1Z", "1S", "1T", "1U", "1V", "1a", "1b", "1h", "1i", "1j", "1k", "1l", "1~", "1!", "1@", "1#", "1$", "1%", "1^", "0*", "0(", "0)", "0_", "0+", "0c", "0d", "0e", "0f", "0|", "0_", "0=", "0\", "0<", "0>", "0/", "0J", "0P", "0Q", "0R", "0W", "0X", "0Y", "0Z", "0S", "0T", "0U", "0V", "0a", "0b", "0h", "0i", "0j", "0k", "0l", "0~", "0!", "0@", "0#", "0$", "0%", "0^")
myinput = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
'求阵列变数的数量
mySec = Second(Now())
a = UBound(myinput())
b = UBound(addPw())
'解密
N1 = Range("a3").Value
myInputLen = Len(N1) - 2
Debug.Print "myinputlen:" & myInputLen
mySec = Right(N1, 2): Debug.Print mySec: j = 0
Do Until mySec < b
If mySec = addPw(j) Then mySec = j: Exit Do Else j = j + 1
Loop
Debug.Print mySec
For i = 1 To myInputLen Step 2
N2 = Mid(N1, i, 2): j = 0
Do Until j = b
If N2 = addPw(j) Then j = j - mySec + 1: N3 = N3 & j: Exit Do Else j = j + 1
Loop
Next
Range("a4").Value = N3
End Sub
a1 是 加密前的文字 a2 是 该字串所代表的数字 a3 加密后的字串 a4 是 解密后的文字 还没写好a4解不出正确的a1 ,但要下班了 趁上班时间偷打的,先放上来,回家再研究
本帖包含附件 |
|
Book2.rar
(2022-06-09 14:01 / 15 KB) |
下载次数: | 9 |
|
|
x0
[4 楼]
From:台湾政府网际
| Posted:2005-01-28 18:41 |
|
|
panasonic732
|
分享:
▲
http://bbs.mychat.to/read.php?tid=117558我写好一个新的编密噜 大概是这样 里面有三种的编密 S1 S2 S3 S4是来乱的 s1 s2 s3是随着时间改变编码 有空我在去想...中文的部分要怎么解决...OK之后 在尝试量多是否能正确执行 DSL的编码 满复杂的 是我们来说... 了解其中的编码后来解救会很快了 例如 jjen2baeO0bafO0aaen1cbn1bafS0bbfk0dcq0ifM2dcs0aabk1babT0aajk1 aafK1ajdO1jgdm2jjdS2cbt1bafT0aaeL1cbt1jiM0cbk1bbcn0babn0bbaK0 bbhs0ajdo1bafl0bbfM0baK2jgdS2aaeq1cbT1jiK0cbO1aabL1jgjT2bbaM0 aafO1baeK0bafL0jjdO2cbQ1jgdQ2bbfQ0baT2ifT2dcM0aabt1jgjT2bbao0 解出来的都是 this is a pen 仔细看我的编码规则就出现噜...呵呵... 一起努力吧 ^^
|
忧虑不断,心未宁静
绵绵春雨,花失娇艳
凋零磨灭,事情难回
得意失意,不再回想
放弃它吧,唯有如此
|
x0
[5 楼]
From:台湾中华电信
| Posted:2005-01-29 01:32 |
|
|
|