Encrypt
The Encrypt function allows you to encrypt result data with a user-defined key, using Blowfish with CBC (cipher block chaining). Then, the encrypted data can be sent to a PC or a remote device using an In-Sight function or a native mode command, where the data is decrypted with a decryption application.
- The Encrypt function is supported on the In-Sight vision systems running firmware version 5.4.0 or later.
- The Encrypt function does not have any character limits. However, In-Sight functions that are used to send the encrypted string to a PC or remote device may have the 255 character limits, and return #ERR (please note that the encrypted string will always be longer than the initial result data before encryption). For more information on the character limits, please refer to each In-Sight function's topic.
- The Cognex In-Sight Encryption sample applications are available for the key generation and decryption.
- For more information on the encryption/decryption mechanism, please refer to the sample code (C:\Users\Public\Documents\Cognex\In-Sight\In-Sight Sample Projects 5.x.x).
Encrypt Inputs
Syntax: Encrypt(Key (Base64),Value,Output Format)
Parameter | Description | ||||
---|---|---|---|---|---|
The key used to encrypt result data (string, Base64 encoded). The recipient will use the same key to decrypt the data. Note: Use EditPassword to prevent the key from being visible to non-admin users. For more information, see EditPassword.
|
|||||
The result data (string) to encrypt. | |||||
Select the method to encode the encrypted data.
|
Encrypt Outputs
Results |
Returns the encrypted string. |
Encrypt Example
In this example, you will encrypt a barcode result decoded by the ReadIDMax function, and then send the encrypted result to a PC using the TCPDevice and WriteDevice functions where the data is decrypted.
- Insert a ReadIDMax function, and decode a barcode. The result string is automatically inserted to the spreadsheet. For more information, see ReadIDMax.
-
Insert an EditPassword function. Enter a key you would like to use to encrypt the result string.
Note: You can use the Cognex In-Sight Encrypt Generator sample application to generate a key. For more information, refer to the Sample Application section. - Insert an Encrypt function, and configure the property sheet as follows:
- Key (Base64): Reference the EditPassword cell.
Value: Reference the ReadIDMax's result string cell.
Note: If the result string requires formatting, use FormatString and reference this function. For more information, see Format String Dialog.- Output Format: Select the desired encoding method (Base64 or Hex).
- The encrypted string is automatically inserted to the spreadsheet. Now you are ready to output the encrypted barcode result to a PC.
-
Insert a TCPDevice function and use the default values to create a TCP server on port 3000. For more information, see TCPDevice.
Note: Remove the ReadDevice cell that was automatically added. - Insert a WriteDevice function. For more information, see WriteDevice.
- Event: Set to A0.
- Device: Reference the TCPDevice cell (step 5).
- Data: Reference the Encrypt cell (step 3).
-
Place the In-Sight vision system Online. Connect with telnet, specifying the Host Name or IP address and port number (for example,
C:\ telnet is8402_010203 3000
), and then trigger the vision system.After each acquisition, the encrypted data will be transmitted.
-
Decrypt the encrypted string using a decryption application. When decrypting, you need the Key entered in the EditPassword cell (step 2).
Note: You can use the Cognex In-Sight Encrypt sample application to decrypt the encrypted string. For more information, refer to the Sample Application section below.
Cognex In-Sight Encrypt Sample Applications
The sample applications are located: C:\Users\Public\Documents\Cognex\In-Sight\In-Sight Sample Projects 5.x.x
Key Generation Sample
This sample application generates a key in Base64 format. You can choose to generate a random key, or a key based on a user provided text.
Decryption Sample
This sample application decrypts a message that was encrypted using the In-Sight Encrypt function.