des

package
v0.0.0-...-8ccda10 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package des 提供 DES / Triple DES 对称加密/解密。 设计要点:

  • 基于标准库 crypto/des 和 crypto/cipher,零外部依赖。
  • 支持 CBC 和 CFB 两种模式。
  • 提供 PKCS#5 填充工具函数。
  • 默认 IV = "I Love Go Frame!"。
  • 注意:DES 已不再安全,建议使用 AES 或 Triple DES(3DES)。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(cipherText, key []byte, iv ...[]byte) ([]byte, error)

Decrypt 使用 DES-CBC 解密(DecryptCBC 的别名)。

func DecryptCBC

func DecryptCBC(cipherText, key []byte, iv ...[]byte) ([]byte, error)

DecryptCBC 使用 DES-CBC 解密。

func DecryptCFB

func DecryptCFB(cipherText, key []byte, iv ...[]byte) ([]byte, error)

DecryptCFB 使用 DES-CFB 解密。

func DecryptTripleCBC

func DecryptTripleCBC(cipherText, key []byte, iv ...[]byte) ([]byte, error)

DecryptTripleCBC 使用 3DES-CBC 解密(key 长度需为 24 字节)。

func Encrypt

func Encrypt(plainText, key []byte, iv ...[]byte) ([]byte, error)

Encrypt 使用 DES-CBC 加密(EncryptCBC 的别名)。

func EncryptCBC

func EncryptCBC(plainText, key []byte, iv ...[]byte) ([]byte, error)

EncryptCBC 使用 DES-CBC 加密。

func EncryptCFB

func EncryptCFB(plainText, key []byte, iv ...[]byte) ([]byte, error)

EncryptCFB 使用 DES-CFB 加密。

func EncryptTripleCBC

func EncryptTripleCBC(plainText, key []byte, iv ...[]byte) ([]byte, error)

EncryptTripleCBC 使用 3DES-CBC 加密(key 长度需为 24 字节)。

func PKCS5Padding

func PKCS5Padding(src []byte, blockSize ...int) []byte

PKCS5Padding 对数据做 PKCS#5 填充。blockSize 可选,默认 8(DES 块大小)。

func PKCS5UnPadding

func PKCS5UnPadding(src []byte, blockSize ...int) ([]byte, error)

PKCS5UnPadding 对 PKCS#5 填充的数据去填充。

func SetDefaultIV

func SetDefaultIV(iv []byte)

SetDefaultIV 修改全局默认 IV。

Types

This section is empty.

Jump to

Keyboard shortcuts

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