drm v0.1.3 Drm View Source

Documentation for Drm. license functions for creating, storing and exporting aes encrypted keys.

Link to this section Summary

Functions

Remove all licenses

Create a new license

Decode a license

Delete a license by filename

Encode a license

Export the license file

Export license keys

check if the appid "fingerprint" exists

Generate a license key based on a hash

Validate that a license struct is valid

Validate that a license struct is valid and matches the fingerprint

Validate an encrypted license string

Validate that an encrypted license is valid and matches the fingerprint

Link to this section Functions

Remove all licenses

Examples

 iex> License.clear()
 :ok

Create a new license

Parameters

  • hash: the license key string
  • meta: a map of meta data to enclude in the license
  • policy: a map of the main policy for the license ### Parameters

    • name : the name of the policy
    • type: the type of policy "free | commercial"
    • expiration: the license experation date this is a Datetime.t -> int ie. DateTime.utc_now() |> to_unix
    • validation_type: the validation type "strict | floating | concurrent"
    • checkin: when to checkin "true | false"
    • checkin_interval: when to checkin "nil | daily | weekly | monthly"
    • max_fingerprints: the number of max fingerprints for this license
    • fingerprint: the fingerprint for this license

      Validation Types

    • strict: a license that implements the policy will be considered invalid if its machine limit is surpassed
    • floating: a license that implements the policy will be valid across multiple machines
    • concurrent: a licensing model, where you allow a set number of machines to be activated at one time, and exceeding that limit may invalidate all current sessions.

      Types

    • free: a free license
    • commercial: a free license

examples

license = %{hash: "license-key12", meta: %{email: "demo@example.com", name: "licensee name"}, policy: %{name: "policy name", type: "free", expiration: nil, validation_type: "strict", checkin: false, checkin_interval: nil, max_fingerprints: nil, fingerprint: "main-app-name-umbrella-app-hash-id"}}

License.create(license)

Decode a license

examples

license_string = "1ASHD7P87VKlA1iC8Q3tdPFCthdeHxSOWS6BQfUv8gsC8yzNg6OeccIErfuKGvRWzzsRyZ7n/0RwE7ZuQCBL4eHPL5zhGCW5JunAKlsorpKdbMWACiv64q/JO3TOCBJSasd0grljX8z2OzKDeEyk7f0xfIleeL0jXfe+rF9/JC4o7vRHTwJS5va6r19fcWWB5u4AxQUw5tsJmcWBVX5TDwTH8WSJr8HK9xto8V6M1DNzNUKf3dLHBr32dVUjM+uNW2W2uy5Cl3LKIPxv+rmwZmTBZ/1kX8VrqE1BXCM7HttiwzmBEmbQJrvcnY5CAiO562HJTAM6C7RFsHGOtrwWINRzCkMxOffAeuHYy6G9S+ngasJBR/0a39HcA2Ic4mz5" License.decode(license_string)

Delete a license by filename

Examples

  iex> License.delete("3454453444")
  {:error, :enoent}

Encode a license

Parameters

  • hash: the license key string
  • meta: a map of meta data to enclude in the license
  • policy: a map of the main policy for the license ### Parameters

    • name : the name of the policy
    • type: the type of policy "free | commercial"
    • expiration: the license experation date this is a Datetime.t -> int ie. DateTime.utc_now() |> to_unix
    • validation_type: the validation type "strict | floating | concurrent"
    • checkin: when to checkin "true | false"
    • checkin_interval: when to checkin "nil | daily | weekly | monthly"
    • max_fingerprints: the number of max fingerprints for this license
    • fingerprint: the fingerprint for this license

      Validation Types

    • strict: a license that implements the policy will be considered invalid if its machine limit is surpassed
    • floating: a license that implements the policy will be valid across multiple machines
    • concurrent: a licensing model, where you allow a set number of machines to be activated at one time, and exceeding that limit may invalidate all current sessions.

      Types

    • free: a free license
    • commercial: a free license

examples

license = %{hash: "license-key", meta: %{email: "demo@example.com", name: "licensee name"}, policy: %{name: "policy name", type: "free", expiration: 55, validation_type: "strict", checkin: false, checkin_interval: nil, max_fingerprints: nil, fingerprint: "main-app-name-umbrella-app-hash-id"}} License.encode(license)

Link to this function

export(id, type \\ "list")

View Source

Export the license file

Examples

 iex> fingerprint = "umbrella-app-id"
 iex> License.export(fingerprint)
 {:error, "fingerprint not found"}
Link to this function

export_keys()

View Source
export_keys() :: Map.t()

Export license keys

examples

License.export_keys()

check if the appid "fingerprint" exists

Examples

 iex> fingerprint = "umbrella-app-id"
 iex> License.fingerprint_valid?(fingerprint)
 false
Link to this function

generate_key(hash, number \\ 1, delimeter \\ "-")

View Source
generate_key(String.t(), Integer.t(), String.t()) :: any()

Generate a license key based on a hash

examples

hash = "4424552325453453"

License.generate_key(hash, 2)

Validate that a license struct is valid

examples license = %{hash: "license-key", meta: %{email: "demo@example.com", name: "licensee name"}, policy: %{name: "policy name", type: "free", expiration: 55, validation_type: "strict", checkin: false, checkin_interval: nil, max_fingerprints: nil, fingerprint: "main-app-name-umbrella-app-hash-id"}} License.is_valid?(license)

Link to this function

is_valid?(license, fingerprint_in_question)

View Source

Validate that a license struct is valid and matches the fingerprint

examples license = %{hash: "license-key", meta: %{email: "demo@example.com", name: "licensee name"}, policy: %{name: "policy name", type: "free", expiration: 55, validation_type: "strict", checkin: false, checkin_interval: nil, max_fingerprints: nil, fingerprint: "main-app-name-umbrella-app-hash-id"}} fingerprint = "main-app-name-umbrella-app-hash-id" License.is_valid?(license, fingerprint)

Link to this function

valid?(license_string)

View Source
valid?(String.t()) :: any()

Validate an encrypted license string

Examples

 iex> license_string = "3454453444"
 iex> License.valid?(license_string)
 false
Link to this function

valid?(license_string, fingerprint_in_question)

View Source
valid?(String.t(), String.t()) :: any()

Validate that an encrypted license is valid and matches the fingerprint

Examples

iex> license_string = "3454453444"
iex> fingerprint = "umbrella-app-id"
iex> License.valid?(license_string, fingerprint)
false