MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / encrypt

Function encrypt

cmd/detail/client.go:220–234  ·  view source on GitHub ↗

encrypt aes-gcm加密

(text, key, nonce []byte)

Source from the content-addressed store, hash-verified

218
219// encrypt aes-gcm加密
220func encrypt(text, key, nonce []byte) (ciphertext, tag []byte) {
221 block, err := aes.NewCipher(key)
222 if err != nil {
223 logs.Error(err)
224 return
225 }
226 aesgcm, err := cipher.NewGCMWithNonceSize(block, len(nonce))
227 if err != nil {
228 logs.Error(err)
229 return
230 }
231 res := aesgcm.Seal(nil, nonce, text, nil)
232 tagIndex := len(res) - tagSize
233 return res[:tagIndex], res[tagIndex:]
234}
235
236// decrypt aes-gcm解密
237func decrypt(ciphertext, key, nonce, tag []byte) (text []byte) {

Callers 1

DetectFunction · 0.85

Calls 1

ErrorFunction · 0.92

Tested by

no test coverage detected