Skip to content

Crypto

Wyn provides cryptographic primitives through the Crypto module. All functions return hex-encoded strings.

Methods

MethodReturnsDescription
Crypto.sha256(s)stringSHA-256 hash (hex)
Crypto.hmac_sha256(key, msg)stringHMAC-SHA256 (hex)

Examples

wyn
// Hash a string
hash = Crypto.sha256("hello")
print(hash)  // 2cf24dba5fb0a30e...

// HMAC for message authentication (e.g., JWT signing)
sig = Crypto.hmac_sha256("secret-key", "message-to-sign")
print(sig)

See Also

  • Bcrypt - password hashing (use this for passwords, not raw SHA-256)
  • Encoding - Base64 and hex encoding
  • Strings - hash results are hex strings

MIT License - v1.21.0