Created
April 16, 2019 04:51
-
-
Save sle-c/1542b0f6b58761b455cb0409f32536a1 to your computer and use it in GitHub Desktop.
A function to get an App object given a public key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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