Class wwEncryption

wwEncryption provides helper functions for two-way string encryption and decryption and one-way string Hash generation.

Two-way Encryption

Encryption refers to two-way encrypting and decrypting of data. Two-way encryption is useful for storing things like secret configuration values that need to be encrypted for storage, but have to be read back later for consumption. Very common for storing configuration values, where the values are significant and contain data needed by the application for later retrieval and usage.

This classes Uses TripleDES for two-way encryption using internal logic for two-way encoding, which is suitable only for encoding and decoding using this class (or the .NET wrapper).


One-way hashes are useful for storing authorization or validation data like passwords or document verification keys.

Hashing is always one way, which means you cannot retrieve the original value from a hashed key. To verify a hash the original value (like a password) has to be provided, which is then re-hashed to compare against a previously stored hash.

The most common use case for hashes is password encryption, where passwords are hashed and stored in a data store. Hashes are created when a password is initially created or generated for a user and that initial hash is saved and stored into a data store. Since the hash is one way the original password is not accessible and therefore can't be easily compromised. To verify the hash at runtime, a user provides the password (or whatever value) to verify in plain text. That input is then hashed using the same hashing values as the originally stored hash and compared to the hash in the data store for a match.

Hash Algorithms supported:

  • MD5
  • SHA1
  • SHA256
  • SHA384
  • SHA512
  • HMACSHA256
  • HMAC384
  • HMAC512

CheckSum Creation

There's also support for computing Checksum values from strings and files using MD5 and SHA256 algorithms.l



Relies uses the .NET Runtime and the wwDotnetBridge library

Class Members



o.ComputeHash(lcText, lcAlgorithm, lvHashSalt)


Decrypts a string with a pass phrase using TripleDES encryption. The Decrypt function should use the same encryption key that was used to encrypt the string.

o.DecryptString(lcEncryptedText, lcEncryptionKey)


Encrypts a string with a pass phrase using TripleDES or AES encryption.

This is a symmetric encryption which requires decryption using the the same algorithm.

o.EncryptString(lcInput, lcEncryptionKey)


Calculates a CheckSum from a binary blob using MD5 or SHA256.

o.GetChecksumFromBytes(lqBytes, lcMode)


Calculates a Checksum from a file using MD5 or SHA256.

o.GetCheckSumFromFile(lcFilename, lcMode)


Creates output for encrypted values in BinHex format instead of the default Base64 format.





Sets the default Encryption key for the EncryptString() / DecryptString() methods if the pass phrase is not passed.

Set during application startup which makes the key global for the application.



Sets the two-way encryption provider used for EncryptString() and DecryptString() and determines whether the encryption key is hashed with MD5.



Assembly: wwencryption.prg

See also:

Class wwDotnetBridge

© West Wind Technologies, 1996-2021 • Updated: 05/26/21
Comment or report problem with topic