crypto

package
v0.1.1-beta Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const BUF_SIZE = 32 * 1024
View Source
const CIPHER_SIZE = BUF_SIZE + 16

Variables

This section is empty.

Functions

func RandomKey

func RandomKey() []byte

生成随机 key 值

func Sha256File

func Sha256File(path string) ([]byte, error)

Types

type Cipher

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

加密文件的结构体,由密钥, aesgcm 对象, nonce 组成

func NewCipher

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

通过 key 和 nonce 生成 Cipher 对象, 传 nil 返回随机值

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(ciphertext []byte) ([]byte, error)

解密字节数组

func (*Cipher) DecryptFile

func (c *Cipher) DecryptFile(inpath string, outpath string) (string, error)

解密文件, inpath 加密文件路径, outpath 输出文件路径(可选), 默认返回 inpath + ".out"

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(plaintext []byte) ([]byte, error)

加密字节数组

func (*Cipher) EncryptFile

func (c *Cipher) EncryptFile(inpath string, outpath string) (string, error)

加密文件, inpath 输入文件的路径, outpath 加密文件的路径(可以传空字符串), 默认返回 inpath + ".mn1" 结尾的路径

Jump to

Keyboard shortcuts

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