Search the Community
Showing results for tags 'Function not found in the dll'.
-
Here is my vb .net code. This works from a console application, however this is not working while being called from an AutoIt script using DLLCall. Can someone tell me what I am doing wrong? Console Application: Module Module1 Sub Main() Dim strEncrypt As String = Decide("Encrypt", "Hello") Console.WriteLine("The encrypted value is: " & strEncrypt) Console.ReadLine() Dim strDecrypt As String = Decide("Decrypt", strEncrypt) Console.WriteLine("The decrypted value is: " & strDecrypt) Console.ReadLine() End Sub End Module VB.NET DLL Code Imports System.IO Imports System.Text Imports System.Security.Cryptography Public Class Crypto Private Shared DES As New TripleDESCryptoServiceProvider Private Shared MD5 As New MD5CryptoServiceProvider Private Shared Function MD5Hash(ByVal value As String) As Byte() Return MD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(value)) End Function Private Shared Function Encrypt(ByVal stringToEncrypt As String, ByVal key As String) As String DES.Key = Crypto.MD5Hash(key) DES.Mode = CipherMode.ECB Dim Buffer As Byte() = ASCIIEncoding.ASCII.GetBytes(stringToEncrypt) Return Convert.ToBase64String(DES.CreateEncryptor().TransformFinalBlock(Buffer, 0, Buffer.Length)) End Function Private Shared Function Decrypt(ByVal encryptedString As String, ByVal key As String) As String Try DES.Key = Crypto.MD5Hash(key) DES.Mode = CipherMode.ECB Dim Buffer As Byte() = Convert.FromBase64String(encryptedString) Return ASCIIEncoding.ASCII.GetString(DES.CreateDecryptor().TransformFinalBlock(Buffer, 0, Buffer.Length)) Catch ex As Exception 'MessageBox.Show("Invalid Key", "Decryption Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) 'Console.WriteLine("Invalid Key - Decryption Failed") Return "ERROR" End Try End Function Public Shared Function Decide(ByVal strEncryptOrDecrypt As String, ByVal strParameter As String) As String Dim EncryptionKey As String = "Decryption String Goes Here!" If strEncryptOrDecrypt = "Encrypt" Then Dim strEncrypted As String = Crypto.Encrypt(strParameter, EncryptionKey) Return strEncrypted ElseIf strEncryptOrDecrypt = "Decrypt" Then Dim strDecrypted As String = Crypto.Decrypt(strParameter, EncryptionKey) Return strDecrypted Else Return "ERROR" End If End Function End Class AutoIt code: $myDll = @ScriptDir & "\Encryption.dll" $result = DllCall($myDll, "str", "Decide", "str", "Encrypt", "str", "Happy") MsgBox(0,"@Error", @error)