Skip to content

Latest commit

 

History

History
70 lines (45 loc) · 4.24 KB

serial_number.md

File metadata and controls

70 lines (45 loc) · 4.24 KB

SerialNumber Class: 'support/serial_number.php'

The SerialNumber class generates and validates encrypted 16 character serial numbers.

SerialNumber::Generate($productid, $userinfo, $options)

Access: public static

Parameters:

  • $productid - An integer between 0 and 1023 inclusive. Useful for identifying a specific product.
  • $userinfo - A string containing sanitized user-supplied information (e.g. a lowercase e-mail address).
  • $options - An array containing options for the data to be included in the serial number and encryption information.

Returns: A standard array of information.

This static function generates an 80-bit encrypted and encoded serial number based on the input information.

The $options array accepts these options:

  • expires - A boolean indicating whether or not the serial number expires (Default is false). This option affects how the date option is interpreted.
  • date - An integer containing a UNIX timestamp representing the date of issuance OR the date of expiration (Default is the current time).
  • product_class - An integer between 0 and 15 inclusive for identifying a product classification such as Standard vs. Pro vs. Enterprise (Default is 0).
  • major_ver - An integer between 0 and 255 inclusive for identifying the major version number of the product that the license is for (Default is 1).
  • minor_ver - An integer between 0 and 255 inclusive for identifying the minor version number of the product that the license is for (Default is 0).
  • custom_bits - An integer between 0 and 31 inclusive for custom bits of application-specific data to include in the serial number (Default is 0).
  • encode_chars - A string containing exactly 32 byte characters to use to encode the serial number (Default is 'abcdefghijkmnpqrstuvwxyz23456789').
  • encrypt_secret - Required. A string containing at least 20 randomly generated bytes to use for the HMAC SHA-1 secret for encrypting the per-major version serial number.
  • validate_secret - Required. A string containing at least 20 randomly generated bytes to use for the HMAC SHA-1 secret for the per-major version validation portion of the serial number.

The encrypt_secret and validate_secret options are required and should be changed for every major version of the software product (e.g. 1.x to 2.x) so that users will have to obtain new serial numbers to use the new version.

SerialNumber::Verify($serial, $productid = -1, $userinfo = false, $options = array())

Access: public static

Parameters:

  • $serial - A string containing a serial number produced by Generate().
  • $productid - An integer between 0 and 1023 inclusive. Useful for identifying a specific product (Default is -1).
  • $userinfo - A string containing sanitized user-supplied information (e.g. a lowercase e-mail address) (Default is false).
  • $options - An array containing options for decoding and decrypting the serial number (Default is array()).

Returns: A standard array of information.

This static function validates, decodes, and decrypts a serial number as far as it can.

The $options array accepts these options:

  • decode_chars - A string containing exactly 32 byte characters to use to encode the serial number (Default is 'abcdefghijkmnpqrstuvwxyz23456789').
  • decrypt_secret - A string containing at least 20 randomly generated bytes to use for the HMAC SHA-1 secret for encrypting the per-major version serial number.
  • validate_secret - A string containing at least 20 randomly generated bytes to use for the HMAC SHA-1 secret for the per-major version validation portion of the serial number.

When not supplied with a decryption secret, this function simply verifies that the serial number contains the correct number of valid characters.

SerialNumber::SNTranslate($format, ...)

Access: internal static

Parameters:

  • $format - A string containing valid sprintf() format specifiers.

Returns: A string containing a translation.

This internal static function takes input strings and translates them from English to some other language if CS_TRANSLATE_FUNC is defined to be a valid PHP function name.