public Sub EncryptString(plainText As String, password As String) As String
Dim encryptor As Cipher
Dim mDigest As MessageDigest
Dim bConv As ByteConverter
Dim baseConv As Base64
Dim key() As Byte = 'Same password of php with salt
Dim keygen As KeyGenerator
keygen.Initialize("AES")
keygen.KeyFromBytes(key)
Try
encryptor.Initialize("AES/CBC/PKCS7Padding")
encryptor.InitialisationVector = Array As Byte(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
Dim aryEncrypted() As Byte = encryptor.Encrypt(bConv.StringToBytes(plainText, "ASCII"), keygen.Key, True)
Dim retBase As String = baseConv.EncodeBtoS(aryEncrypted, 0, aryEncrypted.Length)
Return retBase
Catch
Log(LastException)
End Try
Return ""
End Sub
public Sub DecryptString(cipherText As String, password As String) As String
Dim encryptor As Cipher
Dim mDigest As MessageDigest
Dim bConv As ByteConverter
Dim baseConv As Base64
Dim key() As Byte = 'Same password of php with salt
Dim keygen As KeyGenerator
keygen.Initialize("AES")
keygen.KeyFromBytes(key)
Try
encryptor.Initialize("AES/CBC/PKCS7Padding")
encryptor.InitialisationVector = Array As Byte(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
Dim cipherAry() As Byte = baseConv.DecodeStoB(cipherText)
Dim aryPlain() As Byte = encryptor.Decrypt(cipherAry, keygen.key, True)
Dim retBase As String = bConv.StringFromBytes(aryPlain, "ASCII")
Return retBase
Catch
Log(LastException)
End Try
Return ""
End Sub