希望有人能夠幫助我。將VB.NET加密方法轉換爲PHP
我非常需要這個VB.NET代碼轉換爲PHP。
這是我收到的指令:
要測試你的加密,這些密鑰進行加密,下列單詞,如果你得到了相同的結果檢查:
文本加密:MYPASSWORD
鹽鍵:* & ^%$#@ @!
PBE密鑰:FWV70700
PBE IV:WEBSV
注:
密文:A + V3JATKUt/T91HiF23eOA ==
以下是一個短VB.Net代碼段會做加密,我們需要。 VB的程序有一個表格(1跳轉)有兩個文本框(TextBox1中1和TextBox)和一個按鈕(按鈕1):
VB.NET功能:
Imports System
Imports System.IO
Imports System.Xml
Imports System.Text
Imports System.Security.Cryptography
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = EncryptText(TextBox1.Text)
End Sub
Public Shared Function EncryptText(ByVal strText As String) As String
Dim pdbPassword As PasswordDeriveBytes
Dim pdbIV As PasswordDeriveBytes
Dim DES As New DESCryptoServiceProvider
Dim salt() As Byte = {Asc("*"), Asc("&"), Asc("^"), Asc("%"), Asc("$"), Asc("#"), Asc("@"), Asc("!")}
Dim ms As New System.IO.MemoryStream
Dim cs As CryptoStream
Dim plainText As String = strText
Dim plainBytes() As Byte
plainBytes = System.Text.Encoding.UTF8.GetBytes(plainText)
pdbPassword = New PasswordDeriveBytes("FWV70700", salt)
pdbPassword.HashName = "SHA1"
pdbPassword.IterationCount = 1000
DES.Key = pdbPassword.GetBytes(8)
pdbIV = New PasswordDeriveBytes("WEBSV", salt)
pdbIV.HashName = "SHA1"
pdbIV.IterationCount = 1000
DES.IV = pdbIV.GetBytes(8)
cs = New CryptoStream(ms, DES.CreateEncryptor, CryptoStreamMode.Write)
cs.Write(plainBytes, 0, plainBytes.Length)
cs.FlushFinalBlock()
Return Convert.ToBase64String(ms.ToArray)
End Function
可能有人請其轉換爲PHP爲了我?
堆棧溢出不在這裏做你的工作。 – Oswald
如果你不想自己做這個嘗試[rent-a-coder](http://www.rent-acoder.com/)? –