AesCbc

package
v0.0.0-...-7e13a3b Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

README

aesCbc

aesCbc加密解密

为什么要实现?

go本身不支持256位aes加密,而我又需要这个功能

实现原理

aes-cbc-128:使用的是golang自带的功能

aes-cbc-256:把libmcrypt这个库的c语言实现,用go重新实现了一下

实现原理:将c语言翻译成go语言

Documentation

Index

Constants

View Source
const (
	BLOCK_SIZE_16 = 16
)
View Source
const (
	BLOCK_SIZE_32 = 32
)

Variables

View Source
var (
	InCo = []byte{0xB, 0xD, 0x9, 0xE} /* Inverse Coefficients */

)

Fixed Data

Functions

func AesDecrypt

func AesDecrypt(key, iv []byte, encrData []byte) []byte

解密

func AesEncrypt

func AesEncrypt(key, iv []byte, origData []byte) []byte

加密

func ROTL

func ROTL(x byte) byte

rotates x one bit to the left

func ROTL16

func ROTL16(x uint32) uint32

func ROTL24

func ROTL24(x uint32) uint32

func ROTL8

func ROTL8(x uint32) uint32

Rotates 32-bit word left by 1, 2 or 3 byte

Types

type AesCipher128

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

func NewAesCipher128

func NewAesCipher128(key, iv []byte) *AesCipher128

func (*AesCipher128) BlockSize

func (aesCipher *AesCipher128) BlockSize() int

func (*AesCipher128) Decrypt

func (aesCipher *AesCipher128) Decrypt(encrData []byte) []byte

func (*AesCipher128) Encrypt

func (aesCipher *AesCipher128) Encrypt(origData []byte) []byte

type AesCipher256

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

func NewAesCipher256

func NewAesCipher256(key, iv []byte) *AesCipher256

func (*AesCipher256) BlockSize

func (aesCipher *AesCipher256) BlockSize() int

func (*AesCipher256) Decrypt

func (aesCipher *AesCipher256) Decrypt(origData []byte) []byte

func (*AesCipher256) Encrypt

func (aesCipher *AesCipher256) Encrypt(origData []byte) []byte

type IAesCipher

type IAesCipher interface {
	Encrypt(origData []byte) []byte
	Decrypt(origData []byte) []byte
}

func NewAesCipher

func NewAesCipher(key, iv []byte) IAesCipher

type RI

type RI struct {
	Nk int
	Nb int
	Nr int
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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