crypto

package
v0.0.0-...-075a84e Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertPublicKeyToSPKI

func ConvertPublicKeyToSPKI(publicKey *rsa.PublicKey) ([]byte, error)

ConvertPublicKeyToSPKI converts an RSA public key to SPKI DER format

func Decrypt

func Decrypt(block cipher.Block, iv, ciphertext []byte) []byte

Decrypt decrypts the ciphertext using CFB8 mode with the given block cipher and IV. It returns the plaintext which will be the same length as the ciphertext.

func Encrypt

func Encrypt(block cipher.Block, iv, plaintext []byte) []byte

Encrypt encrypts the plaintext using CFB8 mode with the given block cipher and IV. It returns the ciphertext which will be the same length as the plaintext.

func ExtractPublicKeyFromPEM

func ExtractPublicKeyFromPEM(publicKeyPEM string) ([]byte, error)

ExtractPublicKeyFromPEM extracts the raw public key bytes from a PEM string

func MinecraftSHA1

func MinecraftSHA1(s string) string

MinecraftSHA1 creates the SHA1 hash digest of the given Minecraft username, used for auth on server side. Original implementation: https://gist.github.com/toqueteos/5372776

func NewDecryptStream

func NewDecryptStream(block cipher.Block, iv []byte) cipher.Stream

NewDecryptStream creates a cipher.Stream for decryption using CFB8.

func NewEncryptStream

func NewEncryptStream(block cipher.Block, iv []byte) cipher.Stream

NewEncryptStream creates a cipher.Stream for encryption using CFB8.

func ParseRSAPrivateKey

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

ParseRSAPrivateKey parses an RSA private key from PEM format Supports both PKCS#8 and PKCS#1 formats

func ParseRSAPublicKey

func ParseRSAPublicKey(publicKeyPEM string) (*rsa.PublicKey, error)

ParseRSAPublicKey parses an RSA public key from PEM format Supports both PKIX and PKCS#1 formats

Types

type Encryption

type Encryption struct {
	// contains filtered or unexported fields
}

func NewEncryption

func NewEncryption() *Encryption

func (*Encryption) Decrypt

func (e *Encryption) Decrypt(data []byte) []byte

func (*Encryption) DecryptWithPrivateKey

func (e *Encryption) DecryptWithPrivateKey(privateKey *rsa.PrivateKey, data []byte) ([]byte, error)

func (*Encryption) EnableEncryption

func (e *Encryption) EnableEncryption() error

func (*Encryption) Encrypt

func (e *Encryption) Encrypt(data []byte) []byte

func (*Encryption) EncryptWithPublicKey

func (e *Encryption) EncryptWithPublicKey(publicKeyBytes []byte, data []byte) ([]byte, error)

func (*Encryption) GenerateSharedSecret

func (e *Encryption) GenerateSharedSecret() ([]byte, error)

func (*Encryption) GetSharedSecret

func (e *Encryption) GetSharedSecret() []byte

func (*Encryption) IsEnabled

func (e *Encryption) IsEnabled() bool

func (*Encryption) SetSharedSecret

func (e *Encryption) SetSharedSecret(secret []byte)

type MinecraftSHA1Builder

type MinecraftSHA1Builder struct {
	hash.Hash
}

MinecraftSHA1Builder provides a way to build Minecraft-style SHA1 hashes

func NewMinecraftSHA1

func NewMinecraftSHA1() *MinecraftSHA1Builder

NewMinecraftSHA1 creates a new Minecraft SHA1 builder

func (*MinecraftSHA1Builder) HexDigest

func (m *MinecraftSHA1Builder) HexDigest() string

HexDigest returns the Minecraft-style hex digest

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

Stream exposes a cipher.Stream-compatible wrapper for CFB8.

func (*Stream) XORKeyStream

func (s *Stream) XORKeyStream(dst, src []byte)

XORKeyStream satisfies cipher.Stream.

Jump to

Keyboard shortcuts

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