MCPcopy Create free account
hub / github.com/Peithon/scLoader / DesEncrypt

Function DesEncrypt

core/encrypt.go:11–21  ·  view source on GitHub ↗

DES加密 CBC模式

(origData, key []byte)

Source from the content-addressed store, hash-verified

9
10//DES加密 CBC模式
11func DesEncrypt(origData, key []byte) ([]byte, error) {
12 block, err := des.NewCipher(key)
13 if err != nil {
14 return nil, err
15 }
16 origData = PKCS5Padding(origData, block.BlockSize())
17 blockMode := cipher.NewCBCEncrypter(block, key)
18 crypted := make([]byte, len(origData))
19 blockMode.CryptBlocks(crypted, origData)
20 return crypted, nil
21}
22
23func PKCS5Padding(cipherText []byte, blockSize int) []byte {
24 padding := blockSize - len(cipherText)%blockSize

Callers 1

CmdStartFunction · 0.85

Calls 1

PKCS5PaddingFunction · 0.85

Tested by

no test coverage detected