Home > Language Reference > Classes > StreamCipher
InitAES Method
Sets the encoding/decoding scheme to AES.
Syntax
Public Sub InitAES(ByRef sKey As String, ByVal iKeyLen As Integer, Optional ByVal lSize As Long = 0)
| Parameter | Description |
| sKey | Private key. |
| iKeyLen | Key length expressed in number of bits. |
| lSize | Number of bytes to encode/decode or zero. |
Remarks
The InitAES method sets the encoding/decoding scheme to AES, and allocates the necessary internal buffers. If the object was already initialized, buffers allocated for the previous encoding scheme are freed, and any pending data are lost.
AES is a block encryption algorithm adopted as a standard by the US government. It does not run as quickly as other algorithms, but it is expected to be highly secure. Detailed information on AES can easily be found on the internet.
The algorith needs a private key, which must be specified in the sKey parameter at the time the object is initialized, and cannot be changed later. For security reasons, it is strongly advised not to store this private key in your executable, as in the following naive example:
Dim c As New StreamCipher c.InitAES "A Private Key" ' This string can easily be found in your compiled executable
Instead, you should encrypt the key itself, and/or store it in a separate database. If the design of your application allows this, an even more secure approach would be not to store the key, but to derive it from available data. For example, you could generate a key by applying a secure hash function to the device serial number, or to any user input such as a password.
A key length is also required in the iKeyLen parameter. Note that this is not the actual size of the string specified in the sKey parameter, but the strength of the encryption. This parameter is expressed in number of bits, and can be either 128, 192 or 256. Any other value raises a runtime error.
Finally, the lSize parameter specifies the total number of bytes to be encoded or decoded, and selects the mode of operation as described below:
In either mode of operation, the Flush method must always be called to finalize operations.
System requirements
| System | Minimal version | Remarks |
| Palm OS | Palm OS 3.0 | N/A |