Did this article resolve your question/issue?



4GL/ABL: The one-way uniqueness of the Progress 4GL ENCODE function

« Go Back


Title4GL/ABL: The one-way uniqueness of the Progress 4GL ENCODE function
URL Name21685
Article Number000127756
EnvironmentProduct: OpenEdge
Version 10.x, 11.x
Product: Progress
Version: 8.x, 9.x
OS: All supported platforms
Question/Problem Description
4GL/ABL: The one way uniqueness of the Progress 4GL ENCODE function

What does the Progress 4GL ENCODE function do?

Can the action of the Progress 4GL ENCODE function be reversed?

What algorithm is used by the Progress 4GL ENCODE function?
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
The Progress 4GL ENCODE Function takes a character string as input and returns a 16 character long encoded string.
Although the same source character string always yields a unique result the reverse is not true. That is the action of the Progress 4GL ENCODE function is not reversible and there is no 4GL function that would return the original source string by acting upon its encrypted value.
The Progress 4GL ENCODE function uses a CRC-16 algorithm to generate its encoded output. This calculation involves a mathematical computational process that applies a polynomial value on the string.

The ENCODE function works on the byte values of the character string. The same character string in a different codepage can have different byte values, so the result of ENCODE will be different in that case.
The Progress 4GL ENCODE function operates on strings containing single as well as double-byte characters; of any length subject to Progress 4GL variable size limitations; and performs a one-way encoding operation that is irreversible.

That is:
If cStringA = cStringB  then ENCODE(cStringA) = ENCODE(cStringB).
If ENCODE(cStringA) = ENCODE(cStringB) then cStringA may or may not be equal to cStringB.
In other words it is not possible to determine the original string from the result returned by the Progress 4GL ENCODE function.

Note that while cStringA eq cStringB is case-insensitive, and so e.g. "test" eq "Test" will evaluate to True, the returned encoded strings will be different.
References to Other Documentation:
OpenEdge Development: ABL Reference

Progress Article(s):
What is the algorithm used by the ENCODE() 4GL function?
Last Modified Date10/26/2020 10:42 AM
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.