xtea

package
v0.0.0-...-512269d Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const BlockSize = 8

XTEA block size in bytes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

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

A Cipher is an instance of an XTEA cipher using a particular key.

func NewCipher

func NewCipher(key []byte) (*Cipher, error)

NewCipher 构造器. key 只能长度 16 bytes.

func (*Cipher) BlockSize

func (c *Cipher) BlockSize() int

BlockSize 返回XTEA block size,结果为常量. 方法来满足package "crypto/cipher" 的 Block interface

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(dst, src []byte)

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(dst, src []byte)

Encrypt 加密 src参数8byte buffer内容,明文保存在dst里面. 注意data的长度大于block, 在连续的block上调用encrypt是不安全的,应该使用 CBC crypto/cipher/cbc.go 那种方式来encrypt

type KeySizeError

type KeySizeError int

KeySizeError 自定义错误

func (KeySizeError) Error

func (k KeySizeError) Error() string

Error .

Jump to

Keyboard shortcuts

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