mirror of
https://github.com/github/codeql.git
synced 2026-08-03 17:03:02 +02:00
21 lines
394 B
Go
21 lines
394 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
)
|
|
|
|
func encryptValueGood(v interface{}) ([]byte, error) {
|
|
jsonData, err := json.Marshal(v)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if len(jsonData) > 64*1024*1024 {
|
|
return nil, errors.New("value too large")
|
|
}
|
|
size := len(jsonData) + (len(jsonData) % 16)
|
|
buffer := make([]byte, size)
|
|
copy(buffer, jsonData)
|
|
return encryptBuffer(buffer)
|
|
}
|