security

package
v2.0.53 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultAesKey   = `159054a86e3bfb85b5f1991cdb07645e`
	BlockSize       = 16 // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
	DefaultAesNBits = 256
	CryptoAesName   = "aes"
)
View Source
const (
	DefaultRC4Key = "159054a86e3bfb85b5f1991cdb07645e"

	CryptoRC4Name string = "rc4"
)
View Source
const (
	CryptoRSAName   = "rsa"
	RsaPublicKeyTpl = `-----BEGIN PUBLIC KEY-----
%s
-----END PUBLIC KEY-----`
	RsaPrivateKeyTpl = `-----BEGIN RSA PRIVATE KEY-----
%s
-----END RSA PRIVATE KEY-----`
)

Variables

This section is empty.

Functions

func ComparePassword

func ComparePassword(hashedPassword, currPassword string, saltStr string) bool

ComparePassword Check if two passwords compare

Types

type AesCipher

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

func NewAesCipher

func NewAesCipher(key string, nBits int) (*AesCipher, error)

func (*AesCipher) BlockSize

func (a *AesCipher) BlockSize() int

func (*AesCipher) DecodeURIComponent

func (a *AesCipher) DecodeURIComponent(str string) string

func (*AesCipher) Decrypt

func (a *AesCipher) Decrypt(cipherText string) ([]byte, error)

func (*AesCipher) EncodeURIComponent

func (a *AesCipher) EncodeURIComponent(str string) string

func (*AesCipher) Encrypt

func (a *AesCipher) Encrypt(plaintext string) (string, error)

func (*AesCipher) String

func (a *AesCipher) String() string

type AesCipherConfig

type AesCipherConfig struct {
	Key  string `json:"key" yaml:"key"`
	Bits int    `json:"bits" yaml:"bits"`
}

type AesKeySizeError

type AesKeySizeError int

func (AesKeySizeError) Error

func (k AesKeySizeError) Error() string

type Crypto

type Crypto interface {
	String() string
	Encrypt(plaintext string) (string, error)
	Decrypt(cipherText string) ([]byte, error)
}

type Encrypt

type Encrypt struct {
	Password string
	Salt     string
}

func EncryptPassword

func EncryptPassword(password string) *Encrypt

type Rc4Cipher

type Rc4Cipher struct {
	Key string `json:"key" yaml:"key"`
}

func NewRc4Cipher

func NewRc4Cipher(key string) *Rc4Cipher

func (*Rc4Cipher) CiphertextFormat

func (r *Rc4Cipher) CiphertextFormat(ciphertext string) string

CiphertextFormat Client encrypt content format

func (*Rc4Cipher) CiphertextReplace

func (r *Rc4Cipher) CiphertextReplace(ciphertext string) string

func (*Rc4Cipher) DecodeURIComponent

func (r *Rc4Cipher) DecodeURIComponent(str string) string

func (*Rc4Cipher) Decrypt

func (r *Rc4Cipher) Decrypt(ciphertext string) ([]byte, error)

func (*Rc4Cipher) EncodeURIComponent

func (r *Rc4Cipher) EncodeURIComponent(str string) string

func (*Rc4Cipher) Encrypt

func (r *Rc4Cipher) Encrypt(plaintext string) (string, error)

func (*Rc4Cipher) RandInt

func (r *Rc4Cipher) RandInt(min, max int) int

func (*Rc4Cipher) Rc4ClientDecrypt

func (r *Rc4Cipher) Rc4ClientDecrypt(ciphertext string) (string, error)

Rc4ClientDecrypt Client RC4 Config file Decrypt

func (*Rc4Cipher) Rc4ClientEncrypt

func (r *Rc4Cipher) Rc4ClientEncrypt(plaintext string) (string, error)

Rc4ClientEncrypt Client RC4 Config file Encrypt

func (*Rc4Cipher) String

func (r *Rc4Cipher) String() string

type Rc4CipherConfig

type Rc4CipherConfig Rc4Cipher

type RsaCipher

type RsaCipher struct {
	PubKey     string
	PriKey     string
	PublicKey  *rsa.PublicKey
	PrivateKey *rsa.PrivateKey
}

func NewRsaCipher

func NewRsaCipher(pubKey, priKey string) (*RsaCipher, error)

func (*RsaCipher) DecodeURIComponent

func (a *RsaCipher) DecodeURIComponent(str string) string

func (*RsaCipher) Decrypt

func (a *RsaCipher) Decrypt(cryptText string) (plainText []byte, err error)

func (*RsaCipher) EncodeURIComponent

func (a *RsaCipher) EncodeURIComponent(str string) string

func (*RsaCipher) Encrypt

func (a *RsaCipher) Encrypt(plainText string) (cryptText string, err error)

func (*RsaCipher) String

func (a *RsaCipher) String() string

type RsaCipherConfig

type RsaCipherConfig struct {
	PublicKey  string `yaml:"publicKey" json:"publicKey"`
	PrivateKey string `yaml:"privateKey" json:"privateKey"`
}

type RsaCiphersConfig

type RsaCiphersConfig struct {
	Client RsaCipherConfig `yaml:"client" json:"client"`
	Server RsaCipherConfig `yaml:"server" json:"server"`
}

Jump to

Keyboard shortcuts

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