MCPcopy Create free account
hub / github.com/Preloading/TwitterAPIBridge / GenerateKey

Function GenerateKey

cryption/authcrypt.go:18–24  ·  view source on GitHub ↗

GenerateKey generates a new AES key and returns it as a base64 encoded string

()

Source from the content-addressed store, hash-verified

16
17// GenerateKey generates a new AES key and returns it as a base64 encoded string
18func GenerateKey() (string, error) {
19 key := make([]byte, 32) // AES-256
20 if _, err := io.ReadFull(rand.Reader, key); err != nil {
21 return "", err
22 }
23 return base64.StdEncoding.EncodeToString(key), nil
24}
25
26// Encrypt encrypts the given plaintext using AES-GCM with the provided base64 encoded key and returns the ciphertext as a base64 encoded string
27func Encrypt(plaintext, base64Key string) (string, error) {

Callers 1

access_tokenFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected