NiceCuppaTea
asked on
VB.Net from Perl Encryption
Hi Experts,
Im trying to convert a series of scripts that we use internally to a vb.net applicaiton with a GUI that can be passed on to the BAU teams. Unfortunately my knowledg around encryption is pretty non existant.
Would anyone be so kind as to explain to me how to convert the below perl to VB.NET? Or at least point me in the correct direction as far as namespaces etc are concerned?
Here is what i have so far.... not going so great.
Im trying to convert a series of scripts that we use internally to a vb.net applicaiton with a GUI that can be passed on to the BAU teams. Unfortunately my knowledg around encryption is pretty non existant.
Would anyone be so kind as to explain to me how to convert the below perl to VB.NET? Or at least point me in the correct direction as far as namespaces etc are concerned?
use DBI;
use strict;
use warnings;
use Crypt::CBC;
use MIME::Base64;
use Encode;
use Digest::MD5 qw(md5_hex);
use warnings;
my $encrypted = <FILE>;
my $iv = '0000000000000000';
my $utf_decoded = encode_utf8($iv);
my $key = "854EE3617FDDA2D3";
#create Cipher based on AES
my $cipher = Crypt::CBC->new(
-key => $key,
-literal_key => 1,
-iv => pack('H32',$utf_decoded),
-header => 'none',
-padding => 'standard',
-blocksize => 16,
-keysize => 16,
-cipher => "OpenSSL::AES"
);
my @dec = decode_base64($encrypted);
my $count = 0;
foreach my $entry (@dec) {
my $temp = $cipher->decrypt($entry);
$temp =~ s/[\x0D]//g;
$count++;
print "$temp";
}
exit();
Here is what i have so far.... not going so great.
Public Function AES_Decrypt(ByVal input As String)
Dim KeyStr As String = "854EE3617FDDA2D3"
Dim IVstr As String = "0000000000000000"
Dim IV(15) As Byte
For I = 0 To 15
IV(I) = IVstr.Substring(I, 1)
Next
Dim AES As New RijndaelManaged
Dim Hash_AES As New MD5CryptoServiceProvider
Dim decrypted As String = ""
Try
Dim Key() As Byte = Encoding.Unicode.GetBytes(KeyStr)
AES.BlockSize = 128
AES.KeySize = 128
AES.Padding = PaddingMode.PKCS7
AES.Key = Key
AES.IV = IV
AES.Mode = CipherMode.CBC
Dim DESDecrypter As ICryptoTransform = AES.CreateDecryptor
Dim Buffer As Byte() = Convert.FromBase64String(input)
decrypted = Encoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return decrypted
Catch ex As Exception
MsgBox(ex.Message)
Return "error"
End Try
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.