Files
renovate-sh-app[bot]zeekayrenovate-sh-app[bot] <219655108+renovate-sh-app[bot]@users.noreply.github.com>
e9bb098d78 fix(deps): update module github.com/bytedance/sonic to v1.15.0 (#6342)
| datasource | package                    | from    | to      |
| ---------- | -------------------------- | ------- | ------- |
| go         | github.com/bytedance/sonic | v1.14.2 | v1.15.0 |

Signed-off-by: renovate-sh-app[bot] <219655108+renovate-sh-app[bot]@users.noreply.github.com>
Co-authored-by: renovate-sh-app[bot] <219655108+renovate-sh-app[bot]@users.noreply.github.com>
2026-02-22 00:55:20 -08:00

45 lines
1.0 KiB
Go

// +build amd64,go1.17,!go1.27
package rt
import (
_ "unsafe"
"github.com/cloudwego/base64x"
)
func DecodeBase64(raw []byte) ([]byte, error) {
ret := make([]byte, base64x.StdEncoding.DecodedLen(len(raw)))
n, err := base64x.StdEncoding.Decode(ret, raw)
if err != nil {
return nil, err
}
return ret[:n], nil
}
func EncodeBase64ToString(src []byte) string {
return base64x.StdEncoding.EncodeToString(src)
}
func EncodeBase64(buf []byte, src []byte) []byte {
if len(src) == 0 {
return append(buf, '"', '"')
}
buf = append(buf, '"')
need := base64x.StdEncoding.EncodedLen(len(src))
if cap(buf) - len(buf) < need {
tmp := make([]byte, len(buf), len(buf) + need*2)
copy(tmp, buf)
buf = tmp
}
base64x.StdEncoding.Encode(buf[len(buf):cap(buf)], src)
buf = buf[:len(buf) + need]
buf = append(buf, '"')
return buf
}
//go:linkname SubrB64Decode github.com/cloudwego/base64x._subr__b64decode
var SubrB64Decode uintptr
//go:linkname SubrB64Encode github.com/cloudwego/base64x._subr__b64encode
var SubrB64Encode uintptr