MCPcopy Index your code
hub / github.com/pocketbase/pocketbase / Decrypt

Function Decrypt

tools/security/encrypt.go:42–62  ·  view source on GitHub ↗

Decrypt decrypts encrypted text with key (must be valid 32 chars AES key). This method uses AES-256-GCM block cypher mode.

(cipherText string, key string)

Source from the content-addressed store, hash-verified

40//
41// This method uses AES-256-GCM block cypher mode.
42func Decrypt(cipherText string, key string) ([]byte, error) {
43 block, err := aes.NewCipher([]byte(key))
44 if err != nil {
45 return nil, err
46 }
47
48 gcm, err := cipher.NewGCM(block)
49 if err != nil {
50 return nil, err
51 }
52
53 nonceSize := gcm.NonceSize()
54
55 cipherByte, err := base64.StdEncoding.DecodeString(cipherText)
56 if err != nil {
57 return nil, err
58 }
59
60 nonce, cipherByteClean := cipherByte[:nonceSize], cipherByte[nonceSize:]
61 return gcm.Open(nil, nonce, cipherByteClean, nil)
62}

Callers 6

TestEncryptFunction · 0.92
TestDecryptFunction · 0.92
loadParamMethod · 0.92
TestSettings_DBExportFunction · 0.92
loadOldSettingsFunction · 0.92
BindSecurityFunction · 0.92

Calls 1

OpenMethod · 0.65

Tested by 3

TestEncryptFunction · 0.74
TestDecryptFunction · 0.74
TestSettings_DBExportFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…