Encode

(System Library)

Description: Processes a VTScada string using a configurable selection of compression, encryption, encoding and secure hashing.
Returns: String
Usage: Script Only.
Function Groups: Encryption
Related to: Decode | BlockEncrypt | Base64Encode | Hash |Pack
Format: System.Encode(PlainValue[, PackDictionary, Compressed, Key, SaltLength, HashKey, Base64Encoded]);
Parameters:  
PlainValue
Required. The information to be encoded. May be any VTScada value that can be packed.
PackDictionary
Optional dictionary. If present, the information will be packed. Refer to notes for the Pack function for further details about this parameter.

Compressed

Optional Boolean. Set TRUE if the value is to be compressed before possible encryption. No compression is done unless this value is specified as TRUE.
Key
Optional. Key to be used as a seed for encryption.
SaltLength
Optional numeric. Length of salt in bytes to use for encryption ( 0-64 ) Not relevant unless the Key parameter is also valid. Defaults to zero.
HashKey
Optional text. If valid, an SHA2-256 hash will be added to the end of the result to prevent tampering. This string is used to seed/salt the hash.
Base64Encoded
Optional Boolean. Set true if the result is to be Base64 encoded.
Comments:

Note that if Base64 encoding is selected, the time required to encode and also to decode the information will increase by a factor of approximately ten.

Examples:

 If Watch(1);
  [
    Secret = System.Encode("Hello");
    NotSecret = System.Decode(Secret);
  ]