utils

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package utils provides cryptographic and general-purpose utility functions.

Index

Constants

View Source
const (
	// PEMTypeRSAPrivateKey is the PEM block type for PKCS#1 RSA private keys.
	PEMTypeRSAPrivateKey = "RSA PRIVATE KEY"
	// PEMTypePrivateKey is the PEM block type for PKCS#8 private keys.
	PEMTypePrivateKey = "PRIVATE KEY"
)

Variables

View Source
var (
	// ErrInvalidPrivateKey is returned when the PEM block cannot be
	// decoded or the key bytes are invalid.
	ErrInvalidPrivateKey = errors.New("failed to decode PEM block")
	// ErrNotRSAKey is returned when a PKCS#8 key is not an RSA private key.
	ErrNotRSAKey = errors.New("not an RSA private key")
	// ErrInvalidPEMType is returned when the PEM block type is not RSA PRIVATE KEY or PRIVATE KEY.
	ErrInvalidPEMType = errors.New("unexpected PEM block type")
)

Functions

func HashString

func HashString(s string) string

HashString returns the SHA-256 hex digest of a string, prefixed with "sha256:" to identify the algorithm used.

func ParseRSAPrivateKey

func ParseRSAPrivateKey(pemStr string) (*rsa.PrivateKey, error)

ParseRSAPrivateKey decodes a PEM-encoded RSA private key. It supports both PKCS#1 (RSA PRIVATE KEY) and PKCS#8 (PRIVATE KEY) formats.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL