Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateFromPayload ¶
func GenerateFromPayload(privateKey *rsa.PrivateKey, payload interface{}) (string, error)
GenerateFromPayload takes a rsa.PrivateKey and a payload to include in the license and returns a license key string (if there are no errors). While this works without any extra effort for built-in data types (such as int, string), if you want to use custom structs as payload, you'll need to register the struct before calling GenerateFromPayload with the gob.Register function. See example above.
func ReadPrivateKey ¶
func ReadPrivateKey(filename string) (*rsa.PrivateKey, error)
ReadPrivateKey reads a PEM-encoded X.509 RSA private key and returns a rsa.PrivateKey that can be used in GenerateFromPayload to generate a license key from a payload.
func ReadPublicKey ¶
ReadPublicKey reads a PEM-encoded X.509 RSA public key and returns a rsa.PublicKey that can be used in VerifyAndExtractPayload to verify a license key and extract the included payload.
func VerifyAndExtractPayload ¶
VerifyAndExtractPayload takes a rsa.PublicKey and a license key string generated with GenerateFromPayload to return an empty interface holding the included payload. A nil interface and an error is returned if the license key is invalid or corrupt. You are expected to assert and convert it to your type; remember that this may cause a panic if you convert to a concrete different type than the one you generated the license key with.
Types ¶
This section is empty.