所以我想做一個函數,可以加密和解密到Base64,然後用一個鍵XOR它。VB.net Base64 + XOR
這裏是我到目前爲止的代碼:
Imports System.Text
Module Module1
Private key As String = "37526"
Sub Main()
Dim test As String = Console.ReadLine
test = Decrypt(test)
Console.WriteLine(test)
Main()
End Sub
Public Function Decrypt(CipherText As String) As String
Dim decoded = Convert.FromBase64String(CipherText)
Dim dexored = [xor](decoded, key)
Return Encoding.UTF8.GetString(dexored)
End Function
Private Function [xor](text As Byte(), key As String) As Byte()
Dim res As Byte() = New Byte(text.Length - 1) {}
For c As Integer = 0 To text.Length - 1
res(c) = CByte((text(c)) Xor CUInt(Val(c Mod key.Length)))
Next
Return res
End Function
Public Function Encrypt(Plaintext As String)
Dim encoded = Encoding.UTF8.GetBytes(Plaintext)
Dim xored = [xor](encoded, key)
Return Convert.ToBase64String(xored)
End Function
End Module
因此,這裏是我的問題:這個代碼工作正常,但我試圖解密此字符串「X1hZXVoCBQY =」,該字符串的解密應該是「lolol123 」。我不知道我的代碼是否有錯,或者密鑰不正確。有人可以檢查我的代碼或給我正確的密鑰嗎?我試圖暴力破解這個關鍵,但這個結果對我來說並不合適。如果我嘗試解密字符串,我沒有得到「lolol123」,我得到「_Y [^^」
Base64不是加密。 XORing的東西不是加密 - 它最多是模糊的 – Plutonix
@Plutonix,thnkx爲了澄清 – MikeWe
仍然沒有解決;( – MikeWe