LanguageValues and typesStandard typesSecurity
EncryptedValue
On this page
A value sealed by crypto.encrypt.
Use it to store something you must read back later, such as a provider's token. crypto.encrypt(value, key: key, context: context) gives the bytes, with a key from your settings. For a value you only need to compare, use Hash or PasswordHash.
Shape
One value, held as bytes, with no parts. As text it reads AQGhssPUGBkaGxwdHh8gISIjJCUmJygpKissLS4vaGVsbG+QkZKTlJWWl5iZmpucnZ6f.
Example
type NotSealed = Failure { kind: FailureKind.invalid_value message: "That isn't a sealed value."}var example: EncryptedValue = attempt text.parse( "AQGhssPUAAECAwQFBgcICQoLDA0ODxAREhMUFRYXgIGCg4SFhoeIiYqLjI2Ojw==", as: EncryptedValue) { malformed: NotSealed}assert example == example
EncryptedValue(bytes) checks them, and bytes that aren't one break the format rule.
text.parse(raw, as: EncryptedValue) reads one from text that comes from outside. Text that isn't one at all fails malformed.
Good to know
- It may be stored and sent. Only
crypto.decrypt, with the key, reads what it holds. ==tells you whether two are the same.<andlist.sort_bydon't take it.
In JSON
A string, in a request, a response or json.write:
"AQGhssPUAAECAwQFBgcICQoLDA0ODxAREhMUFRYXgIGCg4SFhoeIiYqLjI2Ojw==""AQGhssPUGBkaGxwdHh8gISIjJCUmJygpKissLS4vaGVsbG+QkZKTlJWWl5iZmpucnZ6f"
Details
Text form, storage, how it is shown, and operations
EncryptedValue is in the group Security, and has been in Jadpo since 0.1.0.
Text form
text.from writes one standard text form, the same form text.parse reads back: AQGhssPUAAECAwQFBgcICQoLDA0ODxAREhMUFRYXgIGCg4SFhoeIiYqLjI2Ojw== and AQGhssPUGBkaGxwdHh8gISIjJCUmJygpKissLS4vaGVsbG+QkZKTlJWWl5iZmpucnZ6f.
How it is stored
It is stored in one column named for the field, of type bytea. AQGhssPUGBkaGxwdHh8gISIjJCUmJygpKissLS4vaGVsbG+QkZKTlJWWl5iZmpucnZ6f is stored as E'\\x0101a1b2c3d418191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f68656c6c6f909192939495969798999a9b9c9d9e9f'::bytea.
How it is shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
AQGhssPUAAECAwQFBgcICQoLDA0ODxAREhMUFRYXgIGCg4SFhoeIiYqLjI2Ojw== |
AQGhssPUAAECAwQFBgcICQoLDA0ODxAREhMUFRYXgIGCg4SFhoeIiYqLjI2Ojw== |
AQGhssPUGBkaGxwdHh8gISIjJCUmJygpKissLS4vaGVsbG+QkZKTlJWWl5iZmpucnZ6f |
AQGhssPUGBkaGxwdHh8gISIjJCUmJygpKissLS4vaGVsbG+QkZKTlJWWl5iZmpucnZ6f |
Operations
It also takes text.parse, text.from, text.format, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-encrypted-value.md.Built from Jadpo main at aee2e8f.