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

Function decrypt

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

Source from the content-addressed store, hash-verified

60}
61
62func decrypt(data []byte, passphrase string) []byte {
63 key := []byte(createHash(passphrase))
64 block, err := aes.NewCipher(key)
65 if err != nil {
66 panic(err.Error())
67 }
68 gcm, err := cipher.NewGCM(block)
69 if err != nil {
70 panic(err.Error())
71 }
72 nonceSize := gcm.NonceSize()
73 nonce, ciphertext := data[:nonceSize], data[nonceSize:]
74 plaintext, err := gcm.Open(nil, nonce, ciphertext, nil)
75 if err != nil {
76 panic(err.Error())
77 }
78 return plaintext
79}

Callers 1

DecryptFunction · 0.85

Calls 2

createHashFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected