safe

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockModeCBC = 0x00
)

Variables

View Source
var SecretEnvName = "GLOBAL_ENCRYPT_KEY"

Functions

func Decrypt

func Decrypt(cipherString, key string) ([]byte, error)

func Encrypt

func Encrypt(originalBytes []byte, key string, o *EncryptOptions) (string, error)

func WithFixAlgo added in v1.2.5

func WithFixAlgo(o *EncryptOptions)

func WithoutFixAlgo added in v1.2.5

func WithoutFixAlgo(o *EncryptOptions)

Types

type BlockMode

type BlockMode byte

func (BlockMode) NewDecrypter

func (g BlockMode) NewDecrypter(b cipher.Block, iv []byte) cipher.BlockMode

func (BlockMode) NewEncrypter

func (g BlockMode) NewEncrypter(b cipher.Block, iv []byte) cipher.BlockMode

type EncryptOptions

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

func NewEncryptOptions

func NewEncryptOptions(ofs ...WithOptionsFunc) *EncryptOptions

type EncryptionAlgorithm

type EncryptionAlgorithm byte
const (
	Algorithm3DES EncryptionAlgorithm = 0
	AlgorithmDES  EncryptionAlgorithm = 1
	AlgorithmAES  EncryptionAlgorithm = 2
	AlgorithmTEA  EncryptionAlgorithm = 3
)

func (EncryptionAlgorithm) NewCipher

func (algo EncryptionAlgorithm) NewCipher(key []byte) (cipher.Block, error)

func (EncryptionAlgorithm) String

func (algo EncryptionAlgorithm) String() string

type PaddingMethod

type PaddingMethod byte
const (
	PKCS5Padding PaddingMethod = 0x00
)

func (PaddingMethod) Padding

func (p PaddingMethod) Padding(data []byte, blockSize int) ([]byte, int, error)

func (PaddingMethod) UnPadding

func (p PaddingMethod) UnPadding(data []byte, paddingLength int) ([]byte, error)

type String

type String struct {
	Value string
	// contains filtered or unexported fields
}

func NewEncryptedString

func NewEncryptedString(plain, secret string) *String

func (String) MarshalJSON

func (e String) MarshalJSON() ([]byte, error)

func (String) MarshalJSONPB

func (e String) MarshalJSONPB(_ *jsonpb.Marshaler) ([]byte, error)

func (*String) ProtoMessage

func (e *String) ProtoMessage()

func (*String) Reset

func (e *String) Reset()

func (String) Size

func (e String) Size() int

func (*String) String

func (e *String) String() string

func (*String) UnmarshalJSON

func (e *String) UnmarshalJSON(bytes []byte) (err error)

func (*String) UnmarshalJSONPB

func (e *String) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, bytes []byte) error

func (*String) UnmarshalYAML added in v1.2.6

func (e *String) UnmarshalYAML(value *yaml.Node) (err error)

func (String) UnsafeString

func (e String) UnsafeString() (string, error)

func (*String) XXX_WellKnownType

func (e *String) XXX_WellKnownType() string

type WithOptionsFunc

type WithOptionsFunc func(o *EncryptOptions)

func WithAlgorithm

func WithAlgorithm(algo EncryptionAlgorithm) WithOptionsFunc

func WithMode

func WithMode(mode BlockMode) WithOptionsFunc

func WithPadding

func WithPadding(padding PaddingMethod) WithOptionsFunc

Jump to

Keyboard shortcuts

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