Skip to main content
Helper methods for working with licenses, signatures, machine codes and Web API results. Namespace: SKM.V3.Methods
Version: 4.0.54. Both packages; all six documented target frameworks.

Properties

WindowsOnly

Only set this setting if you plan to target Windows only. It’s only necessary in rare cases. If you have any questions, please contact [email protected].
Type: bool

Methods

ComputePasswordHash(string)

Computes a string hash of a password using PBKDF2. Note, in comparison to using hash algorithms such as SHA256, the algorithm used in this method slows down the computation on purpose, to make sure it is harder to guess the original password.
Parameters Returns: string. A Base64-encoded JSON pair containing the salt and derived password hash. Checks: Uses PBKDF2 with 50,000 iterations and a 32-byte derived value. A random 32-byte salt is generated when salt is null. Failure Behavior: Invalid password or salt arguments can throw.

ComputePasswordHash(string, byte[])

Computes a string hash of a password using PBKDF2. Note, in comparison to using hash algorithms such as SHA256, the algorithm used in this method slows down the computation on purpose, to make sure it is harder to guess the original password.
Parameters Returns: string. A Base64-encoded JSON pair containing the salt and derived password hash. Checks: Uses PBKDF2 with 50,000 iterations and a 32-byte derived value. A random 32-byte salt is generated when salt is null. Failure Behavior: Invalid password or salt arguments can throw.

GetAssemblyHash()

Computes a SHA-512 hash of the selected assembly file.
Returns: AssemblySignature. An AssemblySignature containing the file path and Base64 hash, or null if the file cannot be found or read. Failure Behavior: An unavailable entry assembly can throw when no path is supplied. With no path, this uses Assembly.GetEntryAssembly(). It does not verify a license or sign the assembly.

GetAssemblyHash(string)

Computes a SHA-512 hash of the selected assembly file.
Parameters Returns: AssemblySignature. An AssemblySignature containing the file path and Base64 hash, or null if the file cannot be found or read. Failure Behavior: An unavailable entry assembly can throw when no path is supplied. With no path, this uses Assembly.GetEntryAssembly(). It does not verify a license or sign the assembly.

GetFloatingLicenseInformation(ActivateModel, KeyInfoResult)

Calculates used, available and overdraft seats from supplied floating-license counts.
Parameters Returns: FloatingLicenseInformation. FloatingLicenseInformation with UsedDevices, AvailableDevices and OverdraftDevices. Checks: This is a calculation; it does not contact the server or renew a seat. Failure Behavior: The response overload requires non-null activation, license and metadata objects. AvailableDevices is MaxNoOfMachines + MaxOverdraft - UsedFloatingMachines. The caller must supply current counts; the result is not a live occupancy query.

GetFloatingLicenseInformation(int, int, int)

Calculates used, available and overdraft seats from supplied floating-license counts.
Parameters Returns: FloatingLicenseInformation. FloatingLicenseInformation with UsedDevices, AvailableDevices and OverdraftDevices. Checks: This is a calculation; it does not contact the server or renew a seat. Failure Behavior: The response overload requires non-null activation, license and metadata objects. AvailableDevices is MaxNoOfMachines + MaxOverdraft - UsedFloatingMachines. The caller must supply current counts; the result is not a live occupancy query.

GetHardiskId()

An alternative way to compute the machine code by relying on the Hardisk Id (assigned by the manufacturer). This is different from Volume Id. Please note: although based on our testing, it should run without admin access, this might not be the case on some machines. Furthermore, this method is specific to Windows and cannot be used on other platforms.
Availability: Standard package: .NET Framework 3.5, .NET Framework 4.6, .NET Framework 4.7, .NET Framework 4.7.1, .NET Framework 4.8, .NET Standard 2.0. Returns: string. The model and serial number from the last disk returned by the Windows management query, or an empty string when no disk is returned. Failure Behavior: Management-query and missing-field errors can throw. Available only in the standard package.

GetMACAddress()

Returns the MAC address of the first active network interface.
Returns: string. The physical address of the first active network interface, or null if none is found. Failure Behavior: Network-interface enumeration can throw. Interface selection can change. This helper does not guarantee a permanent or unique device identity.

GetMachineCode(bool, int)

Returns the machine code of the current device with SHA-256 as the hash function. This method works differently depending on the binaries that you use. By default, machine code is computed using COM, which requires System.Management. This is only supported on Windows, it’s better to set platformIndependent=true. If you use a version of library without System.Management, the platform independent machine code will be computed by default. The supported platforms are Windows, Mac and Linux. Note, sudo access is required if Linux is used. In newer projects, we recommend to always set platformIndependent=true or use GetMachineCodePI(). If version is set to 2, you can get the machine code as in the Python client, assuming similar settings are used. You can read more about it here: https://help.cryptolens.io/faq/index#machine-code-generation Standard package: .NET Framework 3.5, .NET Framework 4.6, .NET Framework 4.7, .NET Framework 4.7.1, .NET Framework 4.8, .NET Standard 2.0.
Cross-platform package: .NET Framework 3.5, .NET Framework 4.6, .NET Framework 4.7, .NET Framework 4.7.1, .NET Framework 4.8, .NET Standard 2.0.
Parameters Returns: string. A machine-code string, or null for some collection failures. Platform-command and access failures can also throw. This helper uses older Windows/System.Management behavior in the standard package. Prefer GetMachineCodePI for new cross-platform integrations, or pass an explicit machine code to the matching helper. The API availability table describes compilation, not whether a platform-specific operation will succeed on every OS.

GetMachineCodePI()

Computes a machine code using the SDK’s platform-independent helper.
Returns: string. A machine-code string. Some collection failures return null; exceptions from platform-specific collection can also propagate. The overload with v defaults to 1. Keep the same version for activation and later checks. Both packages use the platform-independent path here. On Windows, version 2 tries the hardware UUID and then MachineGuid if the UUID is unavailable; version 1 depends on WMIC. Linux and macOS use platform commands. The host must allow the commands and access needed to read the device identity.

GetMachineCodePI(int)

Computes a machine code using the SDK’s platform-independent helper.
Parameters Returns: string. A machine-code string. Some collection failures return null; exceptions from platform-specific collection can also propagate. The overload with v defaults to 1. Keep the same version for activation and later checks. Both packages use the platform-independent path here. On Windows, version 2 tries the hardware UUID and then MachineGuid if the UUID is unavailable; version 1 depends on WMIC. Linux and macOS use platform commands. The host must allow the commands and access needed to read the device identity.

GetOSStats()

Creates a JSON dictionary of the type MachineInfo, which contains OSVersion, OSName and Is64Bit (not available in NET 3.5).
Returns: string. A string representation of the JSON dictionary.

GetPlatform()

Identifies the operating-system family for the current runtime.
Returns: Helpers.OSType. An OSType value. The available detection path depends on the target framework.

HasFeature(LicenseKey, int)

Checks so that a certain Feature is enabled (i.e. it’s set to TRUE).
Parameters Returns: bool. True when the license is non-null, the feature number is between 1 and 8, and that feature is enabled; otherwise false.

HasFeature(LicenseKey, string)

Uses a special data object associated with the license key to determine if a certain feature exists (instead of the 8 feature flags). Formatting: The name of the data object should be ‘cryptolens_features’ and it should be structured as a JSON array. For example,
means f1 and f2 are true. You can also have feature bundling, eg.
which means that f1 and f2 are true, as well as f2.voice and f2.image. You can set any depth, eg. you can have
means f2.voice.all is true as well as f2.voice and f2. The dots symbol is used to specify the “sub-features”. Read more here: https://help.cryptolens.io/web-interface/feature-templates
Parameters Returns: bool. True if the requested feature path is found; false when the feature data or a path segment is absent. Checks: Reads the cryptolens_features data object. Does not verify the license signature. Failure Behavior: Malformed feature JSON or unexpected data shapes can throw.

IsOnRightMachine(LicenseKey, bool, bool, bool)

Checks whether the supplied license lists the expected machine or process identity.
Parameters Returns: bool. True when a matching activation is present; false otherwise. Checks: Matches activation identifiers. It does not check the signature, expiry, blocking or floating-seat deadline. Machine binding requires Maximum Number of Machines greater than 0. For floating licenses, use isFloatingLicense=true and reuse the same process ID for renewals. The overload with an explicit machine code avoids recomputing it. allowOverdraft defaults to false.

IsOnRightMachine(LicenseKey, string, bool, bool)

Checks whether the supplied license lists the expected machine or process identity.
Parameters Returns: bool. True when a matching activation is present; false otherwise. Checks: Matches activation identifiers. It does not check the signature, expiry, blocking or floating-seat deadline. Machine binding requires Maximum Number of Machines greater than 0. For floating licenses, use isFloatingLicense=true and reuse the same process ID for renewals. The overload with an explicit machine code avoids recomputing it. allowOverdraft defaults to false.

IsOnRightMachinePI(LicenseKey, bool, bool, int)

Computes a platform-independent machine code and checks it against the license activations.
Parameters Returns: bool. True for a matching activation; false otherwise. Checks: Matches machine identity only. It does not check the signature, expiry, blocking or floating-seat deadline. Requires Maximum Number of Machines greater than 0. The v argument selects the machine-code algorithm and defaults to 1.

IsSuccessful(BasicResult)

Checks an API result for success.
Parameters Returns: bool. True when the result is non-null and Result is Success; false otherwise. Checks: This does not verify or validate a returned license.

IsVM()

Checks Windows motherboard information for signs of a virtual machine.
Availability: Standard package: .NET Framework 3.5, .NET Framework 4.6, .NET Framework 4.7, .NET Framework 4.7.1, .NET Framework 4.8, .NET Standard 2.0. Returns: bool. True when the motherboard manufacturer or product matches the built-in virtual-machine checks; otherwise false. Failure Behavior: Windows management queries can throw. This is not a guarantee that every virtual machine will be detected.

VerifyPassword(LicenseKey, string, string)

This method verifies the username and password with the information in the LicenseKey object. It provides a way to activate a license on a per user rather than per machine basis. To compute the password, the ComputePasswordHash(string) is used. A tutorial on how everything can be set up is available here: https://help.cryptolens.io/licensing-models/user-based-activations
Parameters Returns: bool. True when the selected activation matches the supplied password hash; otherwise false. Checks: Matches FriendlyName to the username and compares the derived password representation with Mid. It does not verify the license signature. Failure Behavior: Missing activations and some decode failures return false. Malformed salt arrays or Base64 values can throw.

VerifySDKLicenseCertificate(string)

Verifies a signed license file and checks that its stored assembly hash matches the application assembly.
Parameters Returns: LicenseKey. License Key object if the certificate is valid and null otherwise. Checks: Loads the companion .skm file with the supplied RSA public key, then compares the cryptolens_assemblyhash data object’s StringValue with the assembly’s SHA-512 hash. It does not check expiry, blocking or product identity. Failure Behavior: Returns null if loading fails, the data object is missing, or the hashes differ. Missing entry-assembly information or an unreadable assembly file can cause an exception.

VerifySDKLicenseCertificate(string, string, string)

Verifies a signed license file and checks that its stored assembly hash matches the application assembly.
Parameters Returns: LicenseKey. License Key object if the certificate is valid and null otherwise. Checks: Loads the companion .skm file with the supplied RSA public key, then compares the cryptolens_assemblyhash data object’s StringValue with the assembly’s SHA-512 hash. It does not check expiry, blocking or product identity. Failure Behavior: Returns null if loading fails, the data object is missing, or the hashes differ. Missing entry-assembly information or an unreadable assembly file can cause an exception.

FAQ

No. In 4.0.54 these helpers compare the expected machine or process ID with the returned activations. They do not check the floating deadline. Your application must stop licensed work when its last confirmed seat expires. Use the same process ID for renewals, and keep the floating interval consistent across participating processes. See Floating Licenses.
.NET SDK Reference · Reviewed Source Revision