security

package
v1.1.19 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

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 added in v0.3.9

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

func NewAesCipher

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

func (*AesCipher) BlockSize added in v0.3.9

func (a *AesCipher) BlockSize() int

func (*AesCipher) DecodeURIComponent added in v0.4.2

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

func (*AesCipher) Decrypt added in v0.3.9

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

func (*AesCipher) EncodeURIComponent added in v0.4.2

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

func (*AesCipher) Encrypt added in v0.3.9

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

func (*AesCipher) String added in v0.4.2

func (a *AesCipher) String() string

type AesCipherConfig added in v0.4.3

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 added in v0.3.9

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 added in v0.3.9

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

func NewRc4Cipher added in v0.3.9

func NewRc4Cipher(key string) *Rc4Cipher

func (*Rc4Cipher) CiphertextFormat added in v0.3.9

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

CiphertextFormat Client encrypt content format

func (*Rc4Cipher) CiphertextReplace added in v0.3.9

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

func (*Rc4Cipher) DecodeURIComponent added in v0.4.2

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

func (*Rc4Cipher) Decrypt added in v0.3.9

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

func (*Rc4Cipher) EncodeURIComponent added in v0.4.2

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

func (*Rc4Cipher) Encrypt added in v0.3.9

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

func (*Rc4Cipher) RandInt added in v0.3.9

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

func (*Rc4Cipher) Rc4ClientDecrypt added in v0.3.9

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

Rc4ClientDecrypt Client RC4 Config file Decrypt

func (*Rc4Cipher) Rc4ClientEncrypt added in v0.3.9

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

Rc4ClientEncrypt Client RC4 Config file Encrypt

func (*Rc4Cipher) String added in v0.4.2

func (r *Rc4Cipher) String() string

type Rc4CipherConfig added in v0.4.3

type Rc4CipherConfig Rc4Cipher

type RsaCipher added in v0.3.9

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

func NewRsaCipher added in v0.3.9

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

func (*RsaCipher) DecodeURIComponent added in v0.3.9

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

func (*RsaCipher) Decrypt added in v0.3.9

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

func (*RsaCipher) EncodeURIComponent added in v0.3.9

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

func (*RsaCipher) Encrypt added in v0.3.9

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

func (*RsaCipher) String added in v0.4.3

func (a *RsaCipher) String() string

type RsaCipherConfig added in v0.4.3

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

type RsaCiphersConfig added in v0.4.3

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