An Encrypted String Property can hold a single string value, just like a normal string property. The only difference is that the string value is encrypted using AES before it is written to the database, so it can not easily be read by someone who accesses the database using non-Structr methods.

An encrypted string property


An encrypted string property can be used exactly like a normal string property, except that its value is encrypted before it is stored in the database. The property returns the decrypted value if the encryption key is set correctly, or null if no key or the wrong key is set.

The encryption key can either be set globally in structr.conf, or individually for one or more properties / requests. In the latter case, the encryption key has to be set using set_encryption_key() prior to reading from or writing to the property. If no encryption key is set, Structr will return an error indicating that no encryption key is set.

The global encryption key can be overwritten and restored using set_encryption_key(), and

JSON Output
	"query_time": "0.000897187",
	"result_count": 1,
	"result": {
		"encrypted": "the decrypted text, if the key is set correctly"
   	"serialization_time": "0.000051543"


About this article
Last change 2019-05-21