Skip to content

Instantly share code, notes, and snippets.

@stulentsev
Created November 8, 2016 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stulentsev/c40dfa9ad2899c0d54551704d8f73948 to your computer and use it in GitHub Desktop.
Save stulentsev/c40dfa9ad2899c0d54551704d8f73948 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/base64"
"fmt"
"github.com/VirgilSecurity/virgil-sdk-go"
"io/ioutil"
)
func main() {
crypto := virgil.Crypto()
client := virgil.NewClient("<access_token>")
plaintext := []byte("<badge_id>")
appKeyPassword := "<pwd>"
appKeyData, _ := ioutil.ReadFile("/Users/sergio/Downloads/highload2016 - app key.virgilkey")
appKey, _ := crypto.ImportPrivateKey(appKeyData, appKeyPassword)
card, _ := client.GetCard("a7c6cb4fd800a3f2187d5e342f16a2c04b343a1912c8b0b6069e618096f645fb")
encryptedData, _ := card.SignThenEncrypt(plaintext, appKey)
bb := base64.StdEncoding.EncodeToString(encryptedData)
fmt.Println(bb)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment