xaes

package
v0.25.15 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

GoKit - xaes

AES kits for Golang development.

Installation

go get -u github.com/likexian/gokit

Importing

import (
    "github.com/likexian/gokit/xaes"
)

Documentation

Visit the docs on GoDoc

Example

// Encrypt
ciphertext, err := xaes.CBCEncrypt(plaintext, key, iv)
if err != nil {
    panic(err)
}
fmt.Printf("Encrypted: %x", ciphertext)

// Decrypt
plaintext, err := CBCDecrypt(ciphertext, key, iv)
if err != nil {
    panic(err)
}
fmt.Printf("Decrypted: %s", plaintext)

License

Copyright 2012-2024 Li Kexian

Licensed under the Apache License 2.0

Donation

If this project is helpful, please share it with friends.

If you want to thank me, you can give me a cup of coffee.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingEncryptKey is missing encrypt key error
	ErrMissingEncryptKey = errors.New("xaes: key for encrypting is missing")
	// ErrMissingDecryptKey is missing decrypt key error
	ErrMissingDecryptKey = errors.New("xaes: key for decrypting is missing")
	// ErrInvalidIVSize is invalid IV size error
	ErrInvalidIVSize = fmt.Errorf("xaes: length of iv must be %d", aes.BlockSize)
	// ErrInvalidCiphertextSize is invalid ciphertext size error
	ErrInvalidCiphertextSize = fmt.Errorf("xaes: length of ciphertext must be greater than %d",
		aes.BlockSize+sha256.Size)
	// ErrInvalidHmac is invalid hmac error
	ErrInvalidHmac = fmt.Errorf("xaes: hmac is invalid")
	// ErrInvalidPKCS7Padding is invalid pkcs7 padding
	ErrInvalidPKCS7Padding = fmt.Errorf("xaes: invalid PKCS7 padding")
)

Functions

func Author

func Author() string

Author returns package author

func CBCDecrypt

func CBCDecrypt(ciphertext, key, iv []byte) ([]byte, error)

CBCDecrypt do AES CBC decrypt

func CBCDecryptWithHmac added in v0.25.2

func CBCDecryptWithHmac(ciphertext, key []byte) ([]byte, error)

CBCDecryptWithHmac do AES CBC decrypt with HMAC

func CBCEncrypt

func CBCEncrypt(plaintext, key, iv []byte) ([]byte, error)

CBCEncrypt do AES CBC encrypt

func CBCEncryptWithHmac added in v0.25.2

func CBCEncryptWithHmac(plaintext, key, iv []byte) ([]byte, error)

CBCEncryptWithHmac do AES CBC encrypt then HMAC

func License

func License() string

License returns package license

func PKCS7Padding

func PKCS7Padding(data []byte, blockSize int) ([]byte, error)

PKCS7Padding do PKCS7 padding

func PKCS7Unpadding

func PKCS7Unpadding(data []byte) ([]byte, error)

PKCS7Unpadding do PKCS7 unpadding

func Version

func Version() string

Version returns package version

Types

This section is empty.

Jump to

Keyboard shortcuts

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