$wsSecurity module, you can encrypt, decrypt, and hash data. It is used to protect sensitive data such as passwords, tokens, or personal information. In this section, you will learn how to use the various encryption and hash methods.
Module overview
Example / excerpt of$wsSecurity
ƒ() denotes a function.
Methods overview
Templates
The security functions can be used in any template, typically for:- Forms with sensitive data
- Token generation for links
- Password processing in the registration process
- Data transfer to external systems
Variables
No variables are available for$wsSecurity.
Methods
$wsSecurity.decrypt()
Decrypts data that was encrypted with$wsSecurity.encrypt().
Signature$wsSecurity.decrypt(data)
Return valuestring - Decrypted data in plain text.
Parameters
Example that decrypts encrypted data.
$wsSecurity.encrypt()
Encrypts data with an encryption method defined in the shop configuration. The encrypted data can only be decrypted again withdecrypt().
Signature$wsSecurity.encrypt(id, data, encryptionMethod, encoding)
Return valuestring - Encrypted data in WEBSALE format.
Parameters
Example that encrypts data with AES-GCM.
$wsSecurity.encryptManual()
Encrypts data likeencrypt(), but returns the individual components (ciphertext, salt, auth tag) separately. Useful for integration with external systems that expect a different format.
Signature$wsSecurity.encryptManual(id, data, encryptionMethod, encoding)
Return valuemap - Map with the individual encryption parts.
Return fields
Parameters
Example that encrypts data and uses the parts individually:
$wsSecurity.hash()
Calculates a cryptographic hash value of the input data. Hash values are one-way encryptions – they cannot be converted back to the original data. Typical use case: password storage. Signature$wsSecurity.hash(id, data, hashingMethod, encoding)
Return valuestring - Hash value of the data.
Parameters
Example that hashes a password with a configured method.
Actions
No actions are available for$wsSecurity. Encryption and hashing are performed directly through the module’s methods.
