Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Custom Generate with Name and Mail

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support
View previous topic :: View next topic  
Author Message
magixxfactory



Joined: 20 Feb 2006
Posts: 15

PostPosted: Tue May 16, 2006 3:00 pm    Post subject: Custom Generate with Name and Mail Reply with quote

Hi,
I want to use something like the sample of the Custom Generator. I rewrote the sample DLL and changes from one field "Licenced to" to two field "Name" and "eMail".

I generate a key and then I rewrote the CustomLicensedApp. No it needed to add Name, eMail and License key.

Problem is that I now get wrong ckecksum when validating the licence.

The code in the custom app look like this:

private bool ValidLicense(EncryptedLicense license, string licensedName, string licensedMail)
{
if (license.ProductInfo.Length < 2) return false;
string checksum = license.ProductInfo.Substring(1);
return (checksum == EncryptedLicense.Checksum(licensedName) + EncryptedLicense.Checksum(licensedMail));
}

The part in the custom dll I've changed like this:

public override void GetLicenseKeyData(LicenseKeyData data, ICustomer customer, ISale sale)
{
// display a form to get the details from the user
//
LicenseDataForm form = new LicenseDataForm();

// default to the company name
//
if (customer != null)
{
form.LicensedName = customer.FirstName + " " + customer.LastName;
form.LicensedMail = customer.Email;
}
form.ShowDialog();
data.ProductInfo = form.NumProcessors.ToString() + EncryptedLicense.Checksum(form.LicensedName + EncryptedLicense.Checksum(form.LicensedName));
data.Comments = string.Format("Name: {0} Mail-Adresse: {1} Anzahl Lizenzen: {2}", form.LicensedName, form.LicensedMail, form.NumProcessors);
}


Do you have any idea what's wrong. Or a sample for the way I want to do.

Thanks and regards
Uwe
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue May 16, 2006 11:52 pm    Post subject: Reply with quote

If this really is the code you are using then this line is the problem:

Code:
data.ProductInfo = form.NumProcessors.ToString() + EncryptedLicense.Checksum(form.LicensedName + EncryptedLicense.Checksum(form.LicensedName));


Notice where your brackets are - and you have licensedName twice.

When you check it you then have brackets in different location and include the email (as suspect you meant to)

Code:
return (checksum == EncryptedLicense.Checksum(licensedName) + EncryptedLicense.Checksum(licensedMail));


There is actually no point including a checksum for each individual component (eg licensedName and licensedMail). Instead add the strings together and take the checksum of them all. Also the NumProcessors stuff was purely an example - if you don't actually need to control the number of processors don't include it.

eg

Code:
data.ProductInfo = EncryptedLicense.Checksum(form.LicensedName + form.LicensedMail);


Then when you check it:

Code:
private bool ValidLicense(EncryptedLicense license, string licensedName, string licensedMail)
{
return (license.ProductInfo == EncryptedLicense.Checksum(licensedName + licensedMail);
}


To make you code a little more robust it might be a good idea to Trim the strings of blanks before doing Checksum - that way if the user enters some blanks at the start/end of their name if won't have any effect.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group