package xsubtle

import "git.sr.ht/~jamesponddotco/xstd-go/xcrypto/xsubtle"

Package xsubtle provides functions and utilities to extend Go's default crypto/subtle package.

Index

Functions

func ConstantTimeStringEqual

func ConstantTimeStringEqual(given, actual string) bool

ConstantTimeStringEqual performs a constant-time comparison of two strings to prevent timing attacks. It returns true if the strings are equal, false otherwise. The comparison time depends only on the length of the strings and not their contents.

This function is intended for comparing sensitive strings like passwords or authentication tokens. For regular string comparison, use the == operator.

Source Files

compare.go xsubtle.go

Version
v0.13.1 (latest)
Published
Jan 29, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
4 days ago

Tools for package owners.