arrow-refined-types / arrow.refinement.digests / SHA256

SHA256

class SHA256

SHA256 constrains String to be a valid hexadecimal String of length 64

Safe nullable construction

import arrow.refinement.digests.SHA256

SHA256.orNull("9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08")
SHA256.orNull("not-sha256")

Resolved constraints

SHA256.constraints("9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08")
SHA256.constraints("not-sha256")
SHA256.isValid("9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08")
SHA256.isValid("not-sha256")

Folding validation

SHA256.fold("9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", { "failed: $it" }, { "success: $it" })
SHA256.fold("not-sha256", { "failed: $it" }, { "success: $it" })

Unsafe require

SHA256.require("9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08")
try { SHA256.require("not-sha256") } catch (e: IllegalArgumentException) { e.message }

Types

Companion companion object Companion : Refined<String, SHA256>

Properties

value val value: String

Do you like Arrow?

Arrow Org
<