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 stringmeta
: a map of meta data to enclude in the licensepolicy
: a map of the main policy for the license ### Parametersname
: the name of the policytype
: the type of policy "free | commercial"expiration
: the license experation date this is a Datetime.t -> int ie. DateTime.utc_now() |> to_unixvalidation_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 licensefingerprint
: the fingerprint for this licenseValidation Types
strict
: a license that implements the policy will be considered invalid if its machine limit is surpassedfloating
: a license that implements the policy will be valid across multiple machinesconcurrent
: 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 licensecommercial
: 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 stringmeta
: a map of meta data to enclude in the licensepolicy
: a map of the main policy for the license ### Parametersname
: the name of the policytype
: the type of policy "free | commercial"expiration
: the license experation date this is a Datetime.t -> int ie. DateTime.utc_now() |> to_unixvalidation_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 licensefingerprint
: the fingerprint for this licenseValidation Types
strict
: a license that implements the policy will be considered invalid if its machine limit is surpassedfloating
: a license that implements the policy will be valid across multiple machinesconcurrent
: 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 licensecommercial
: 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)
Export the license file
Examples
iex> fingerprint = "umbrella-app-id"
iex> License.export(fingerprint)
{:error, "fingerprint not found"}
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
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)
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)
Validate an encrypted license string
Examples
iex> license_string = "3454453444"
iex> License.valid?(license_string)
false
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