An implementation of the ENCODE() hash function from Progress OpenEdge.
1IntroductionThis is a port of Pieter van Ginkel's C# implementation of the
ENCODE()hash function from Progress OpenEdge. To paraphrasePieter: Progress has declined to make the algorithm for
ENCODE()public, which is problematic when working with legacy systems(particularly where it's been used to hash user passwords). Thisimplementation provides a compatible implementation of the hashfunction.
(hash-bytes #(1 2 3 4)) ;=> #(97 98 109 99 97 110 106 67 108 106 102 120 113 77 76 119)
HASH-BYTES takes a sequence of
(unsigned-byte 8) and returns a
(vector (unsigned-byte 8) 16) that is the bytes of the resulting
2.2(hash-string string &key encoding)Usage:
(hash-string "foo" :encoding :utf-8) ;=> #(108 97 99 100 107 71 106 117 108 105 106 99 108 110 97 97)
HASH-BYTES to hash the input string after
encoding it with the specified encoding. If
:encoding is not
:iso-8559-1 is used.
2.3(hash-string->string string &key in-encoding out-encoding)Usage:
(oe-encode:hash-string->string "foo" :in-encoding :utf-8 :out-encoding :utf-8) ;=> "lacdkGjulijclnaa"
HASH-STRING->STRING works like
HASH-STRING but decodes the
result result into a string before returning it -- the Progress API
operates on and returns strings, so this is likely to be the most
convenient function for working with existing data.
is used to encode the input before hashing and defaults to
:out-encoding is used to decode the resulting hash
bytes as a string and defaults to the value of
Note that the
ENCODE() algorithm ensures that output bytes are
always in the range of alphabetic ASCII characters, so output
encodings that are ASCII-compatible are preferrable.