sha256

fun String.sha256(salt: String = ""): String

Computes the SHA-256 hash of this String with an optional string salt.

Not for passwords. A single fast digest, salted or not, is not a password hash: store passwords with a dedicated password-hashing function such as Argon2id, scrypt, bcrypt or PBKDF2.

Return

the hex-encoded SHA-256 hash

Parameters

salt

the salt string (default empty)


Computes the SHA-256 hash of this String with a byte array salt.

Not for passwords. A single fast digest, salted or not, is not a password hash: store passwords with a dedicated password-hashing function such as Argon2id, scrypt, bcrypt or PBKDF2.

Return

the hex-encoded SHA-256 hash

Parameters

salt

the salt bytes