Giter Site home page Giter Site logo

cryptolens / cryptolens-golang Goto Github PK

View Code? Open in Web Editor NEW
34.0 4.0 8.0 18 KB

Client API to access the functionality of Cryptolens Software Licensing API

Home Page: https://cryptolens.io/

License: MIT License

Go 100.00%
licensing-as-a-service licensing-library licensing golang

cryptolens-golang's Introduction

Cryptolens Licensing for Golang

This library serves to simplify communication with Cryptolens Web API (https://app.cryptolens.io/docs/api).

Note: an updated version of the library (with support for offline activation) can be found in the go_mod branch.

In order to get started with the library, start by

go get github.com/Cryptolens/cryptolens-golang/cryptolens

Now we can use the library in our code. A working example of the following can be found in the examples/example_activate directory.

We start by importing the library with:

import "github.com/Cryptolens/cryptolens-golang/cryptolens"

Now we can activate a license key as follows:

token := "WyI0NjUiLCJBWTBGTlQwZm9WV0FyVnZzMEV1Mm9LOHJmRDZ1SjF0Vk52WTU0VzB2Il0="
publicKey := "<RSAKeyValue><Modulus>khbyu3/vAEBHi339fTuo2nUaQgSTBj0jvpt5xnLTTF35FLkGI+5Z3wiKfnvQiCLf+5s4r8JB/Uic/i6/iNjPMILlFeE0N6XZ+2pkgwRkfMOcx6eoewypTPUoPpzuAINJxJRpHym3V6ZJZ1UfYvzRcQBD/lBeAYrvhpCwukQMkGushKsOS6U+d+2C9ZNeP+U+uwuv/xu8YBCBAgGb8YdNojcGzM4SbCtwvJ0fuOfmCWZvUoiumfE4x7rAhp1pa9OEbUe0a5HL+1v7+JLBgkNZ7Z2biiHaM6za7GjHCXU8rojatEQER+MpgDuQV3ZPx8RKRdiJgPnz9ApBHFYDHLDzDw==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"

licenseKey, err := cryptolens.KeyActivate(token, cryptolens.KeyActivateArguments{
	ProductId:   3646,
	Key:         "MPDWY-PQAOW-FKSCH-SGAAU",
	MachineCode: "289jf2afs3",
})
if err != nil || !licenseKey.HasValidSignature(publicKey) {
	fmt.Println("License key activation failed!")
	return
}

In order to use the code above with your account on cryptolens.io you need to change the constants as follows:

  1. The token need to be changed to a valid access token for your account. Access tokens can be created at https://app.cryptolens.io/User/AccessToken/. In order to be able to use the KeyActivate() function the token needs to have the Activate scope.
  2. The correct value for publicKey for your account can be found when logged in on Cryptolens.io from the menu in the top-right corner ("Hello !") and then Security Settings. Copy paste the value from the Public key field.
  3. The ProductId can be found at the page for the corresponding product at https://app.cryptolens.io/Product.
  4. The Key is the license key string, and would in most cases be entered by the user of the application in some application dependent manner.
  5. The MachineCode is an optional argument allowing you to provide an identifier for which device the application is running on, or something with a similar purpuse. You can read more about the ways it can be computed in this article.

Finally, additional properties of the license key can be checked if desired:

fmt.Printf("License key for product with id: %d\n", licenseKey.ProductId)

if time.Now().After(licenseKey.Expires) {
	fmt.Println("License key has expired")
	return
}

if licenseKey.F1 {
	fmt.Println("Welcome! Pro version enabled!")
} else {
	fmt.Println("Welcome!")
}

Examples

cryptolens-golang's People

Contributors

artemlos avatar svedi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cryptolens-golang's Issues

Missing HasFeature function.

In the cryptolens python version, you can find a HasFeature function which returns if the user owns that feature in the "Feature Template". I'm not able to find this function in the golang version.

No License

The cryptolens library has no license applied to it. This means that we get in to problems with legal if we import it into our software.

Please add a license (BSD, MIT, apache...) to cryptolens-golang so that we can legally import it into our software.

See the licensing policy at pkg.go.dev.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.