oid64/oid64.go

25 lines
415 B
Go
Raw Normal View History

2023-08-03 17:25:00 +02:00
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
}