

The function CreateKey() now utilizes a function called DateTimeToStr(), which creates a string from a DateTime value.
DATE OF MAIL CONVERT TO DATETIME IN VISUAL BASIC LICENSE
This function takes a complete license string (key + optional expiry date), strips off the key, and returns just the expiry date. This function takes a complete license string (key + optional expiry date), strips off the date, and returns just the key. December 31st 2013, the MD5 input string looks like this: If ‘unlimited_time’ is FALSE, and the date is e.g. If ‘unlimited_time’ is TRUE, the MD5 input String looks like this: This function now takes an additional expiry date and a Bool that signalizes if the date should be used.Īlso note, that we are now using a separator between prefix and key, as well as between key and date. If (!licstr.FindLast(MYLICENSE_SEPARATOR, &pos)) return FALSE Įxpirydate = StrToDateTime(licstr.Right(licstr.GetLength() - pos - 1)) If (!licstr.FindFirst(MYLICENSE_SEPARATOR, &pos)) return licstr īool MyLicense::LicStringToExpiryDate(const String &licstr, DateTime &expirydate) String MyLicense::LicStringToKey(const String &licstr) String sKeyInput = MYLICENSE_PREFIX + MYLICENSE_SEPARATOR + (unlimited_time ? String() : (DateTimeToStr(expirydate) + MYLICENSE_SEPARATOR)) + c4dserial.Right(5)

String MyLicense::CreateKey(const String &c4dserial, const DateTime &expirydate, Bool unlimited_time) const LONG CheckLicense(const String &key) const Īnd here are the new implementations from license.cpp. String CreateKey(const String &serial, const DateTime &expirydate, Bool unlimited_time) const Extract expiry date from complete license stringīool LicStringToExpiryDate(const String &licstr, DateTime &expirydate)

String LicStringToKey(const String &licstr) Extract key from complete license string #define MYLICENSE_PREFIX String("MYPLUGIN") The third change is CreateKey(), which now requires arguments like the expiry date and a bool to control whether the date should be part of the license string or not. In the following, we will refer to the MD5 string as “key” and to the complete string including the (optional) expiry date as “license string”.Īdditionally, two includes have been added, which will provide us with the data types and functions required for working with dates. The following version of license.h introduces two new private member functions that will help us parsing the needed information from the license string. That makes it easy to see the date when looking at the file in a text editor, but changes to the date will make the license invalid, since the MD5 key wouldn’t match the date. In the end, the actual license string that goes out to the user will be a combination of the MD5 key and the date in readable form. Additionally, the expiry date must also be used for the key generation, since the key should always be a kind of checksum of all the different license information. That means, we need to include the expiry date as plain text into the license, to be able to check it when the license is loaded. Since we can not decrypt the license key, an additional information like the expiry date has to be both: Encrypted in the license key, and readable in the license key.
