Number of bytes.
A copy of the bytes; mutating it does not touch this value.
StaticcodecTagged-CBOR codec; decode also accepts the untagged form.
StaticfromCreate a new salt from data. Note: Does not validate minimum size to allow for CBOR deserialization.
StaticfromStaticrandomA random salt of length bytes (16 by default); pass rng to make it deterministic.
StaticrandomA random salt of a random length in [minSize, maxSize].
StaticforA random salt sized for a payload of size bytes (5–25% of it, at least the minimum).
Return true if the salt is empty (this is not recommended).
The data as a hexadecimal string.
Get base64 representation.
Get string representation showing the salt's length.
The CBOR tags this type decodes from; the first one is used to encode.
Returns the untagged CBOR encoding (as a byte string).
The tagged CBOR form.
As a UR, typed by the first tag's name.
Staticfrom
Random salt used to decorrelate other information.
A
Saltis a cryptographic primitive consisting of random data that is used to modify the output of a cryptographic function. Salts are primarily used in password hashing to defend against dictionary attacks, rainbow table attacks, and pre-computation attacks. They are also used in other cryptographic contexts to ensure uniqueness and prevent correlation between different parts of a cryptosystem.Unlike a
Noncewhich has a fixed size, aSaltin this implementation can have a variable length (minimum 8 bytes). Different salt creation methods are provided to generate salts of appropriate sizes for different use cases.Minimum Size Requirement
For security reasons, salts must be at least 8 bytes long. Attempting to create a salt with fewer than 8 bytes will result in an error.
CBOR Serialization
Saltimplements the CBOR tagged encoding interfaces, which means it can be serialized to and deserialized from CBOR with a specific tag (TAG_SALT = 40018).UR Serialization
When serialized as a Uniform Resource (UR), a
Saltis represented as a binary blob with the type "salt".Common Uses
Example