Skip to content

Instantly share code, notes, and snippets.

@sle-c
Created April 16, 2019 04:51
Show Gist options
  • Save sle-c/1542b0f6b58761b455cb0409f32536a1 to your computer and use it in GitHub Desktop.
Save sle-c/1542b0f6b58761b455cb0409f32536a1 to your computer and use it in GitHub Desktop.
A function to get an App object given a public key
package app
import (
"encoding/hex"
"fmt"
"github.com/omnisyle/goliauth"
)
func GetApp(publicKey, dbURL string) *App {
app := &App{
PublicKey: publicKey,
dbURL: dbURL,
}
dbApp := app.Get()
secretBytes, err := hex.DecodeString(dbApp.EncryptedSecret)
if err != nil {
panic(err)
}
decryptedKey, err := goliauth.Decrypt(secretBytes)
if err != nil {
panic(err)
}
dbApp.SecretKey = fmt.Sprintf(
"%x",
decryptedKey,
)
return dbApp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment