|
|
EsDES - ActiveX controlEurosource, Gruvbyn 415, S-820 50 LOOS, Sweden This control is a cryptographic control that implements a 64-bit DES-encryption/decryption algorithm. It allows DES encryption of strings, buffers and files in an easy and user friendly way. New features in version 1.1
InstallationTransfer EsDes32.OCX to your \windows\system or \winnt35\system32 directory and register it by executing the command: RegSvr32 \Windows\System\EsDES32.OCXRegSvr32.exe can be found on the Visual Basic 4.0 CD-ROM and in our dll archive (www.eurosource.se). If RegSvr32.exe fails, it's probably because you don't have the MFC 4.0 DLL library installed on your system. This is available from many sources on the Internet including our ftp archive as MFC40DLL.ZIP. Regsvr32.exe is also included in this archive. If you want to check if you already got the files in mfc40dll.zip they are
Cookbook or how to use the EsDES Control
Create a EsDes object for an ASP applicationUse the object ID ESDES.EsDesCtrl.1 when you create an instance of the EsDesCtrl. So the code <object RUNAT="server" PROGID="ESDES.EsDesCtrl.1" id="EsDes"> </object>or set EsDes = server.CreateObject("EsDes.EsDesCtrl.1") will create the object for you.
Set an encrypt/decrypt keyYou can set the key in several ways. As a string, a decimal string and a hexadecimal string. If you read the key back you get it back in the same format as you set it. Using Hexadecimal values
Using a string of comma separated Decimal values
Using a string of characters
Encrypt a stringMost of the methods for EsDES are supplied in pairs as one encryption and one decryption variant. The exception is the EncryptString method which is only supplied as encryption. This is because the result of encryption's can contain zeros in the result and in C/C++, for instance, this is the character that indicate the end of the string. Therefore this method put its result in the buffer and if you want to decrypt its output you have to use the DecryptBuffer method. Sub EncryptString() ' Encrypt a
string in a textbox txtinstr If ( EsDES1.DecryptBuf = True ) Then
End Sub Encrypt a fileTo encrypt an entire file is easy with the EsDES control. In this case we use the common
dialogs control to get the file to encrypt and the output file from the user. Dim fl As Long The status event is generated periodically during the encryption of the file and we can
use the ProgressBar control and use simple code as the following to indicate to the
user how the encryption proceeds. Decrypt a fileYou use code just the same as that above to Encrypt a file. You only change the line fl = EsDES1.EncryptFile Validating the controlWhen you install the control there is also a sample file and a file named cert.txt that you can use to verify the algorithms. How to do this is exemplified in the sample1 file that comes with the control. Check under the Verify DES Algorithm button. Propertiesunsigned char buf(index)With this property you can fetch or set a value in a certain buffer position. You must first set the buffer length with the length property before you can use the buffer. LPSTR DesKeyThis is the DES-key. You can set this key in several ways. Using Hexadecimal values Set it using a string of hexadecimal values e.g. FF20345645872345 Using a string of comma separated Decimal values Set it using a string of decimal values e.g. 12,234,23,1,98,56,99,255 Using a string of characters Set it using a string in this case you should prefix the string with a dollar "$" character e.g. $This is a key string. You will get the key back in the same format as you set it. Before you do any encryption/decryption you have to set this property to a value as it have an unknown value before you do. LPSTR InFileThis is the full path for a file you want to decrypt/encrypt. long LengthThis is the length of the buffer. You must set this property before you can use the buffer. You must always set the buffer to value that is an even multiple of 8. If you don't EsDES will set it to the next highest multiple. LPSTR OutFileThis is the full path to the output file from a decryption/encryption operation. Methods
BSTR Decrypt8(LPCTSTR input)This method decrypts eight characters. The format of the input string can be supplied in several ways and the result is returned in the same format as you give as input. The formats of the input string can be one of the following Using Hexadecimal values Set it using a string of hexadecimal values e.g. FF20345645872345 Using a string of comma separated Decimal values Set it using a string of decimal values e.g. 12,234,23,1,98,56,99,255 Using a string of characters Set it using a string in this case you should prefix the string with a dollar "$" character e.g. $This is a key string. Note that in this case an empty string is returned and the result is returned in the buffer which will have a length of 8. BOOL DecryptBuf()This method encrypts the content of the buffer. You must therefore first set the buffer size with the Length property and then fill it with the data that you want to decrypt. long DecryptFile()With this method you can Decrypt a file. You specify the full path to the file you want to decrypt in the InFile property and the file you want to have as output in the property OutFile. Status events are generated as the decryption proceeds. BSTR Encrypt8(LPCTSTR input)This method encrypts eight characters. The format of the input string can be supplied in several ways and the result is returned in the same format as you give as input. The formats of the input string can be one of the following Using Hexadecimal values Set it using a string of hexadecimal values e.g. FF20345645872345 Using a string of comma separated Decimal values Set it using a string of decimal values e.g. 12,234,23,1,98,56,99,255 Using a string of characters Set it using a string in this case you should prefix the string with a dollar "$" character e.g. $This is a key string. Note that in this case an empty string is returned and the result is returned in the buffer which will have a length of 8. BOOL EncryptBuf()This method encrypts the content of the buffer. You must therefore first set the buffer size with the Length property and then fill it with the data that you want to encrypt. long EncryptFile()With this method you can Encrypt a file. You specify the full path to the file you want to encrypt in the InFile property and the file you want to have as output in the property OutFile. Status events are generated as the encryption proceeds void EncryptString(LPCTSTR input)With this method you can Encrypt a string. As EsDES always work with even multiple of 8 the result, which is placed in the buffer, will have a length that is an even multiple of 8. If you need to store this result away and only want to use the same size for this storage as the original string this is however not a problem. Status events are generated as the encryption proceeds Eventsstatus (short progress)Certain operations take some time to complete. This event gives you information about how much of the job that has been completed. When a lengthy job starts the status event is fired with progress set to 0 and then you get status events until the job is complete and a status event with progress set to 100 is fired. You therefore only need to write the progress to a gauge control to give your users dynamic information. Where to get the control?It is possible that you are reading this documentation without having access to the control itself. If you have Internet access you just need to connect to http://www.eurosource.se and fetch a fully working sample of the control. At this location you can also find samples on how to use the control. We can email the control anywhere in the world if you send us a request to do so. Please state if you want MIME or BINHEX coding. Send request to sales@eurosource.se If you use the unregistered version of the control a splash screen is displayed from time to time reminding you to register.To get rid of this nag-screen you need to register. Information is available at our site. We ship anywhere in the world with World-wide First Class/Airmail if you select this option. The only media supported is 3.5" diskettes.The charge for this type of delivery is $15 (USD) extra. SupportYou can get support by sending email to support@eurosource.se. You can also find relevant information on-line at http://www.eurosource.se We also check the newsgroup comp.lang.basic.visual.3rdparty on a regular basis and will try to help on all questions posted there. How to contact us
|