encrypt

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AESMethodDefault = 0
	AESMethodCBC     = 1
	AESMethodCTR     = 2
)

Variables

This section is empty.

Functions

func AESCBCDecrypt

func AESCBCDecrypt(cipherkey, ciphertext []byte, useBase64 ...bool) ([]byte, error)

AESCBCDecrypt hex decodes a piece of data and then decrypts it using CBC mode. The cipherkey argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func AESCBCEncrypt

func AESCBCEncrypt(cipherkey, plaintext []byte, useBase64 ...bool) []byte

AESCBCEncrypt uses CBC mode to encrypt a piece of data and then encodes it in hex. The cipherkey argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func AESCTRDecrypt

func AESCTRDecrypt(cipherkey, ciphertext []byte, useBase64 ...bool) ([]byte, error)

AESCTRDecrypt hex decodes a piece of data and then decrypts it using CTR mode. The cipherkey argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func AESCTREncrypt

func AESCTREncrypt(cipherkey, plaintext []byte, useBase64 ...bool) []byte

AESCTREncrypt uses CTR mode to encrypt a piece of data and then encodes it in hex. The cipherkey argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func AESDecrypt

func AESDecrypt(cipherkey, ciphertext []byte, useBase64 ...bool) ([]byte, error)

AESDecrypt hex decodes a piece of data and then decrypts it using ECB mode. The cipherkey argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func AESEncrypt

func AESEncrypt(cipherkey, plaintext []byte, useBase64 ...bool) []byte

AESEncrypt uses ECB mode to encrypt a piece of data and then encodes it in hex. The cipherkey argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func Fnv1aToUint32

func Fnv1aToUint32(b []byte) uint32

Fnv1aToUint32 returns the 32-bit FNV-1a hash sum of b.

func Fnv1aToUint64

func Fnv1aToUint64(b []byte) uint64

Fnv1aToUint64 returns the 64-bit FNV-1a hash sum of b.

func Md5

func Md5(b []byte) string

Md5 returns the MD5 checksum string of the data.

func Sha1

func Sha1(b []byte) string

Sha1 returns the sha1 checksum string of the data.

func Sha256

func Sha256(b []byte) string

Sha256 returns the sha256 checksum string of the data.

func Sha512

func Sha512(b []byte) string

Sha512 returns the sha512 checksum string of the data.

Types

type AESCodec

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

AesCodec is simple wrap for AESEncrypt/AESDecrypt/AESCBCEncrypt ...

func NewAESCodec

func NewAESCodec(key []byte, useBase64 bool, method ...aesMethod) *AESCodec

func (*AESCodec) Decrypt

func (a *AESCodec) Decrypt(ciphertext []byte) ([]byte, error)

func (*AESCodec) Encrypt

func (a *AESCodec) Encrypt(ciphertext []byte) []byte

Jump to

Keyboard shortcuts

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