oid64/oid64.go
2023-08-03 17:25:00 +02:00

25 lines
415 B
Go

package oid64
import (
"encoding/base64"
"encoding/hex"
)
func ObjectIDToBase64(oid string) (string, error) {
b, e := hex.DecodeString(oid)
if e != nil {
return "", e
}
s := base64.URLEncoding.EncodeToString(b)
return s, nil
}
func Base64ToObjectID(bid string) (string, error) {
b, e := base64.URLEncoding.DecodeString(bid)
if e != nil {
return "", e
}
s := hex.EncodeToString(b)
return s, nil
}