File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ package encryption
2+
3+ import (
4+ "bytes"
5+ "crypto/cipher"
6+ "crypto/des"
7+
8+ "github.com/vulncheck-oss/go-exploit/output"
9+ )
10+
11+ func PKCS5Padding (src []byte , blockSize int ) []byte {
12+ padding := blockSize - len (src )% blockSize
13+ padtext := bytes .Repeat ([]byte {byte (padding )}, padding )
14+
15+ return append (src , padtext ... )
16+ }
17+
18+ func TripleDesEncryption (key , iv , plainText []byte ) ([]byte , bool ) {
19+ block , err := des .NewTripleDESCipher (key )
20+ if err != nil {
21+ output .PrintFrameworkError (err .Error ())
22+
23+ return nil , false
24+ }
25+
26+ blockSize := block .BlockSize ()
27+ origData := PKCS5Padding (plainText , blockSize )
28+ blockMode := cipher .NewCBCEncrypter (block , iv )
29+ cryted := make ([]byte , len (origData ))
30+ blockMode .CryptBlocks (cryted , origData )
31+
32+ return cryted , true
33+ }
You can’t perform that action at this time.
0 commit comments