所以我想做一个函数,可以加密和解密到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