當前位置:首頁 » 密碼管理 » 多看加密解密

多看加密解密

發布時間: 2023-01-08 04:13:15

㈠ 字元的加密和解密

創建3個文本框名稱分別為:
txtCode 用於顯示加密後的字元串
txtRecode 用於顯示解密後的字元串
txtInput 用於輸入要加密的字元串
創建3個按鈕,名稱分別為:
cmdcls 清屏
cmdcode 加密
cmdrecode 解密

Dim strInput$, Code$, Record$, c As String * 1
Dim i%, length%, iAsc%

Private Sub cmdcls_Click() '清屏
txtCode.Text = ""
txtRecode.Text = ""
txtInput.Text = ""
End Sub

Private Sub cmdcode_Click() '加密
Dim strInput$, Code$, Record$, c As String * 1
Dim i%, length%, iAsc%
strInput = txtInput.Text
length = Len(RTrim(strInput)) '去掉字元串右邊的空格,求真正的長度
Code = ""
For i = 1 To length
c = Mid$(strInput, i, 1) '取第i個字元
Select Case c
Case "A" To "Z" '大寫字母加序數5加密
iAsc = Asc(c) + 5
If iAsc > Asc("Z") Then iAsc = iAsc - 26 '加密後字母超過Z
Code = Code + Chr$(iAsc)
Case "a" To "z"
iAsc = Asc(c) + 5 '小寫字母加序數5加密
If iAsc > Asc("z") Then iAsc = iAsc - 26
Code = Code + Chr$(iAsc)
Case Else '當第i個字元為其它字元時不加密,與加密字元串的前i-1個字元連接
Code = Code + c
End Select
Next i
txtCode.Text = Code '顯示加密後的字元串
End Sub

Private Sub cmdrecode_Click() '解密與加密正好逆處理
Code = txtCode.Text
i = 1
recode = ""
length = Len(RTrim(Code)) '若還未加密,不能解密,出錯
If length = 0 Then J = MsgBox("先加密再解密", 48, "解密出錯")
Do While (i <= length)
c = Mid$(Code, i, 1)
If (c >= "A" And c <= "Z") Then
iAsc = Asc(c) - 5
If iAsc < Asc("A") Then iAsc = iAsc + 26
recode = Left$(recode, i - 1) + Chr$(iAsc)
ElseIf (c >= "a" And c <= "z") Then
iAsc = Asc(c) - 5
If iAsc < Asc("a") Then iAsc = iAsc + 26
recode = Left$(recode, i - 1) + Chr$(iAsc)
Else
recode = Left$(recode, i - 1) + c
End If
i = i + 1
Loop
txtRecode.Text = recode
End Sub

㈡ c#加密後解密判斷秘鑰的值是否一致,比如可以返回true或者false

用正確的skey加密一個字元串,放到方法里邊做對比。

熱點內容
shell腳本main函數 發布:2025-08-21 08:38:27 瀏覽:786
eclipse配置android 發布:2025-08-21 08:36:37 瀏覽:29
qq緩存文件夾在哪裡 發布:2025-08-21 08:31:14 瀏覽:616
python數組中文 發布:2025-08-21 08:29:42 瀏覽:765
掛號源碼 發布:2025-08-21 08:17:06 瀏覽:184
ip如何登錄伺服器 發布:2025-08-21 08:17:03 瀏覽:985
小的壓縮機 發布:2025-08-21 08:11:48 瀏覽:125
精易助手源碼 發布:2025-08-21 08:10:24 瀏覽:842
mysql更新存儲過程 發布:2025-08-21 08:04:52 瀏覽:221
資料庫抓取 發布:2025-08-21 07:31:04 瀏覽:333