security

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

Security

security是一个简单的对称加密算法

License GoDoc Go Report Card

安装

go get github.com/ant-libs-go/security

快速开始

key := "8dssword99.2020%"
rawStr := "abcdefghijklmnopqrstuvwxyz"

mgr := New(key)
encStr := mgr.Encode(rawStr)
decStr, _ := mgr.Decode(encStr)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AesEcb

type AesEcb struct {
	BlockSize   int
	PaddingType PADDING
}

func NewAesEcb

func NewAesEcb(blockSize int, paddingType PADDING) (*AesEcb, error)

func (AesEcb) Decrypt

func (ae AesEcb) Decrypt(key, plaintext []byte) ([]byte, error)

func (AesEcb) Encrypt

func (ae AesEcb) Encrypt(key, plaintext []byte) ([]byte, error)

func (AesEcb) PKCS5Padding

func (ae AesEcb) PKCS5Padding(ciphertext []byte, blockSize int) []byte

func (AesEcb) PKCS5UnPadding

func (ae AesEcb) PKCS5UnPadding(originData []byte) []byte

func (AesEcb) PKCS7Padding

func (ae AesEcb) PKCS7Padding(ciphertext []byte, blockSize int) []byte

func (AesEcb) PKCS7UnPadding

func (ae AesEcb) PKCS7UnPadding(originData []byte) []byte

func (AesEcb) ZeroPadding

func (ae AesEcb) ZeroPadding(ciphertext []byte, blockSize int) []byte

func (AesEcb) ZeroUnPadding

func (ae AesEcb) ZeroUnPadding(originData []byte) []byte

type PADDING

type PADDING int
const (
	ZERO_PADDING  PADDING = 1
	PKCS5_PADDING PADDING = 2
	PKCS7_PADDING PADDING = 3
)

type Security

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

func New

func New(key string) *Security

func (Security) Decode

func (this Security) Decode(data string) (string, error)

func (Security) Encode

func (this Security) Encode(data string) (r string)

func (Security) PKCS7Pad

func (this Security) PKCS7Pad(data []byte) []byte

func (Security) PKCS7UPad

func (this Security) PKCS7UPad(data []byte) []byte

Jump to

Keyboard shortcuts

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