Documentation ¶
Index ¶
- Constants
- Variables
- func Decrypt(cipherString, key string) ([]byte, error)
- func Encrypt(originalBytes []byte, key string, o *EncryptOptions) (string, error)
- func SafeStringHookFunc() func(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error)
- func WithFixAlgo(o *EncryptOptions)
- func WithoutFixAlgo(o *EncryptOptions)
- type BlockMode
- type EncryptOptions
- type EncryptionAlgorithm
- type Hash
- type PaddingMethod
- type String
- func (e *String) Equal(n String) bool
- func (*String) GormDataType() string
- func (e String) MarshalJSON() ([]byte, error)
- func (e String) MarshalJSONPB(_ *jsonpb.Marshaler) ([]byte, error)
- func (e *String) ProtoMessage()
- func (e *String) Reset()
- func (e *String) Scan(value any) error
- func (e *String) SetSecret(secret string)
- func (e *String) SetValue(value string) (err error)
- func (e String) Size() int
- func (e *String) String() string
- func (e *String) UnmarshalJSON(bytes []byte) (err error)
- func (e *String) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, bytes []byte) error
- func (e *String) UnmarshalYAML(value *yaml.Node) (err error)
- func (e String) UnsafeString() (string, error)
- func (e *String) UpdateSecret(secret string)
- func (e String) Value() (driver.Value, error)
- func (e *String) XXX_WellKnownType() string
- type WithOptionsFunc
Constants ¶
View Source
const (
BlockModeCBC = 0x00
)
Variables ¶
View Source
var SecretEnvName = "GLOBAL_ENCRYPT_KEY"
Functions ¶
func SafeStringHookFunc ¶ added in v1.4.0
func SafeStringHookFunc() func(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error)
SafeStringHookFunc Implementation mapstructure.DecodeHookFunc
func WithFixAlgo ¶ added in v1.2.5
func WithFixAlgo(o *EncryptOptions)
func WithoutFixAlgo ¶ added in v1.2.5
func WithoutFixAlgo(o *EncryptOptions)
Types ¶
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
)
type String ¶
type String struct {
// contains filtered or unexported fields
}
func NewEncryptedString ¶
func (*String) GormDataType ¶ added in v1.2.11
func (String) MarshalJSON ¶
func (*String) ProtoMessage ¶
func (e *String) ProtoMessage()
func (*String) UnmarshalJSON ¶
func (*String) UnmarshalJSONPB ¶
func (e *String) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, bytes []byte) error
func (*String) UnmarshalYAML ¶ added in v1.2.6
func (String) UnsafeString ¶
func (*String) UpdateSecret ¶ added in v1.2.12
func (*String) XXX_WellKnownType ¶
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
Click to show internal directories.
Click to hide internal directories.