我需要帮助将其转换为PHP:
Public Function Encrypt(ByVal text As String) As String
Dim charSet1 As String, charSet2 As String, i As Long
Dim pos As Long, encryptedChar, encryptedText
charSet1 = " ?!@#$%^&*()_+|0123456789abcdefghijklmnopqrstuvwxyz.,-~ABCDEFGHIJKLMNOPQRSTUVWXYZ¿¡²³ÀÁÂÃÄÅÒÓÔÕÖÙÛÜàáâãäåض§Ú¥"
charSet2 = " ¿¡@#$%^&*()_+|01²³456789ÀbÁdÂÃghÄjklmÅÒÓqÔÕÖÙvwÛÜz.,-~AàáâãFGHäJKåMNضQR§TÚVWX¥Z?!23acefinoprstuxyBCDEILOPSUY"
For i = 1 To Len(text)
pos = InStr(charSet1, Mid(text, i, 1))
If pos > 0 Then
encryptedChar = Mid(charSet2, pos, 1)
encryptedText = encryptedText + encryptedChar
Else
encryptedText = encryptedText + Mid(text, i, 1)
End If
Next
Encrypt = encryptedText
End Function
从VISUAL BASIC到PHP ......
我正在制作一个文本来散列上面提到的东西,但在PHP中为我的网站..上面的代码是自制的,所以它没有像MD5或SHA1。但是,如果你们知道在Visual Basic 2008中加密和解密MD5的方法,请告诉我! (这也必须适用于PHP)。
答案 0 :(得分:1)
不是将上面的子例程转换为PHP,而是在VB.NET中将字符串转换为MD5 Hash的子例程:
Function getMD5Hash(ByVal strToHash As String) As String
Dim md5Obj As New Security.Cryptography.MD5CryptoServiceProvider
Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
bytesToHash = md5Obj.ComputeHash(bytesToHash)
Dim strResult As String = ""
For Each b As Byte In bytesToHash
strResult += b.ToString("x2")
Next
Return strResult
End Function
在PHP中你可以使用md5函数:
$hashedString = md5(strToHash);
它本质上是一个哈希,你无法解密哈希,你只能哈希它并将它与存储的哈希进行比较。
当然,我必须链接到彩虹桌上的编码恐怖帖子并腌制你的哈希: