加密:
Private Function JiaMi(ByVal varPass As String) As String '参数varPass是需要加密的文本内容
Dim varJiaMi As String * 20
Dim varTmp As Double
Dim strJiaMi As String
Dim I
For I = 1 To Len(varPass)
varTmp = AscW(Mid$(varPass, I, 1))
varJiaMi = Str$(((((varTmp * 1.5) / 5.6) * 2.7) * I))
strJiaMi = strJiaMi &varJiaMi
Next I
JiaMi = strJiaMi
End Function
解密函数:
Private Function JieMi(ByVal varPass As String) As String '参数varPass是需要解密的密文内容
Dim varReturn As String * 20
Dim varConvert As Double
Dim varFinalPass As String
Dim varKey As Integer
Dim varPasslenth As Long
varPasslenth = Len(varPass)
For I = 1 To varPasslenth / 20
varReturn = Mid(varPass, (I - 1) * 20 + 1, 20)
varConvert = Val(Trim(varReturn))
varConvert = ((((varConvert / 1.5) * 5.6) / 2.7) / I)
varFinalPass = varFinalPass &ChrW(Val(varConvert))
Next I
JieMi = varFinalPass
End Function
扩展资料:注意事项
编写加密程序,将用户输入的一个英文句子加密为加密字符串,然后输出加密字符串。假设句子长度不超过100个字符。
根据给定的句子加密函数原型SentenceEncoding,编写函数SentenceEncoding调用给定的字符加密函数CharEncoding完成句子加密。
然后,编写主程序提示用户输入英文句子,然后调用函数SentenceEncoding对句子加密,最后输出加密后的句子。
字符加密规则为大写字母和小写字母均加密为其补码, 我们定义ASCII码值相加为’A’+’Z’即155的两个大写字母互为补码,ASCII码值相加为’a’+’z’即219的两个小写字母互为补码。
空格用@代替,句号以#代替,其它字符用句点代替。
函数原型:
void SentenceEncoding(char *soure,char *code)
功能:对待加密字符串source加密后保存加密字符串到code.
参数:char *soure,指向待加密句子的字符串指针;
char *code 指向加密字符串的字符串指针;
字符加密函数代码。
Private Sub Command1_Click()CurrentY = 0
For i = 1 To 9
If i <= 5 Then
Print Space(9 - i)
For j = 1 To 2 * i - 1
Print "*"
Next j
Else
Print Space(i - 1)
For j = 1 To 2 * (10 - i) - 1
Print "*"
Next j
End If
Next i
End Sub
Private Sub Command2_Click()
CurrentY = 0
Dim a(8) As String, b(8) As String
For i = LBound(a) To UBound(a)
If i <= 4 Then
a(i) = String(2 * i + 1, "*")
b(i) = Space(25 - i)
Else
a(i) = String(2 * (8 - i) + 1, "*")
b(i) = Space(17 + i)
End If
Print b(i) + a(i)
Next i
End Sub
Private Sub Command3_Click()
CurrentY = 0
For i = 1 To 9
If i <= 5 Then
Print Space(43 - i)
Print String(2 * i - 1, "*")
Else
Print Space(33 + i)
Print String(2 * (10 - i) - 1, "*")
End If
Next i
End Sub
Private Sub Form_Load()
Me.Width = 4800
Me.Height = 2640
Command1.Width = 1245: Command1.Height = 315: Command1.Left = 120: Command1.Top = 1830
Command2.Width = 1245: Command2.Height = 315: Command2.Left = 1635: Command2.Top = 1830
Command3.Width = 1245: Command3.Height = 315: Command3.Left = 3150: Command3.Top = 1830
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)