Closed tuupola closed 6 years ago
@tuupola I would like to do this one, I'll let you know here again once it's complete.
Great! Let me know and I will update the docs.
@tuupola I have a work in progress Go implementation of branca at hako/branca. It currently uses libsodium-go, license is MIT.
Any feedback would be appreciated.
Everything looks great! In the examples maybe make two small changes.
I will add some more test vectors to the spec. It has been on my todo list for a while. How big hassle was the installing of libdsodium for Go?
Thanks for the feedback @tuupola
It was a not much of a hassle for me, but it's not as simple as a go get
and you're good to go, it requires additional steps to install, especially on Windows. (which I need to test).
@hako could you send me example usage for Go which I can use here: https://branca.io/
Example should have the same payload and usage as the other examples. Thanks!
@tuupola Here is a short working example based on the ones on the homepage in Go.
package main
import (
"fmt"
"encoding/json"
"github.com/hako/branca"
)
func main() {
brca := branca.NewBranca("supersecretkeyyoushouldnotcommit")
data := struct {
User string `json:"user"`
Scope []string `json:"scope"`
}{
User: "someone@example.com",
Scope: []string{"read", "write", "delete"},
}
jsn, err := json.Marshal(data)
token, err := brca.EncodeToString(string(jsn[:]))
payload, err := brca.DecodeToString(token)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(token)
fmt.Println(payload)
}
Thanks!
Go implementation is missing. Something similar as fernet-go by @kr. Anyone interested in implementing it write me a note here and I will add it to the docs.