MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / encrypt

Function encrypt

cli/pkg/aes/cbc.go:48–60  ·  view source on GitHub ↗
(data []byte, passphrase string)

Source from the content-addressed store, hash-verified

46}
47
48func encrypt(data []byte, passphrase string) []byte {
49 block, _ := aes.NewCipher([]byte(createHash(passphrase)))
50 gcm, err := cipher.NewGCM(block)
51 if err != nil {
52 panic(err.Error())
53 }
54 nonce := make([]byte, gcm.NonceSize())
55 if _, err = io.ReadFull(rand.Reader, nonce); err != nil {
56 panic(err.Error())
57 }
58 ciphertext := gcm.Seal(nonce, nonce, data, nil)
59 return ciphertext
60}
61
62func decrypt(data []byte, passphrase string) []byte {
63 key := []byte(createHash(passphrase))

Callers 1

EncryptFunction · 0.85

Calls 2

createHashFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected