Jump to content
Server Maintenance This Week. ×

Making of a license Key but not random


This topic is 3853 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Dear Filemaker ppl,

 

I was wondering if there is a way to script or function that takes the contents of a field and change that into a unique key with length ofcharacters alpha-numeric.

 

The key should not be random as it should be able to be converted back to the original field contents as it were.

 

eg.

 

field - reg_name - contains a name

 

key to generate through a function 

 

adwesd2 - grewad2 - 2fdfhj - 345fryy- dgfsggs-wer4t5h  (as an example)

 

I am not sure how I would go about doing this and any ideas would be most welcome.

 

I am unaable to atatched a sample file.fmp12 to this post to help out.  I would be happy to email it to you from [email protected] if you send me an email.  I just want to generate based on the field reg_name and have the alphanumeric generated specific to the reg_name field so that if the same name is entered again then the samealpha-numeric would come up if that makers any sense.

 

Thank you in advance

 

 

regards,

Yongzi

 

 

The Code I have is as follows:

Field Build_Type = 6
Field Build_Length =
If ( IsEmpty ( 4 ) or Left ( 4 ; 2 ) = "00" ; "" ;Filter ( 4 ; "0123456789" ) )


/* If ( IsEmpty ( build_type ) or Left ( build_type ; 2 ) = "00" ; "" ;Filter ( build_length ; "0123456789" ) ) */

Field Sample =

Let ( [


type = GetAsNumber ( Left ( build_type ; 2 ) ) ;
lg = build_length ;
string = Case (
build_string = "underscore" ; "_" ;
build_string = "hyphen" ; "-" ;
build_string = "space" ; " " ;


build_string )
] ;

If ( type >0 ; KeyGenerator ( lg ; type ; "" ) ;"" ) & string

)



(Function KeyGenerator)

Let ( [
Counter = HowManyChars ;
Alpha = "qwertzuiopasdfghjkyxcvbnm" ;
Beta = "QWERTZUIPASDFGHJKLYXCVBNM" ;
Numeric = "23456789" ;
Special = ",.-;:_%&$=?!" ;

xSet =

 

Case(
Parameter = 1 ; Alpha ;
Parameter = 2 ; Beta ;
Parameter = 3 ; Numeric ;
Parameter = 4 ; Special ;
Parameter = 5 ; Alpha & Beta ;
Parameter = 6 ; Numeric & Alpha & Beta ;
Parameter = 7 ; Alpha & Beta & Numeric & Special ;
Parameter = 8 ; Numeric & Alpha ;
Parameter = 9 ; Beta & Numeric ;
Parameter = 10 ; Numeric & Special ) ;

xLen= Length (xSet)]
;

If ( Counter > 0 ;
Let(String = String & Middle( xSet ; Int(Random*xLen) + 1; 1); String) & KeyGenerator (Counter-1; Parameter; String)
;
String )
)

 

Link to comment
Share on other sites

These two requirements are not the same thing:
 

if the same name is entered again then the samealpha-numeric would come up
it should be able to be converted back to the original field contents


It's possible to use a "one-way function" to generate a non-random key that will meet the first requirement but not the second. It would also help to understand the purpose of this exercise. This could get pretty complex if it needs to be (reasonably) secure.

  • Like 1
Link to comment
Share on other sites

Currently,

 

I have a name field that gets converted to a serial number by means of a logic combining the name, nic, and hostname.

 

The result - serial nuumber - is what I want to use to generate a key from that is unique to that serial number only.

 

The key should be alpha-numeric and some 16 or 20 or 24 characters long.

 

Currently the function with field above in the code in first post does generate a random key but not based on the field I specifiy and further will not be unique.  that is my problem in getting it unique and based on a serial number already generated as a result of the conversion logic.

 

Yongzi

Link to comment
Share on other sites

I am afraid I am still confused:

 

The combination of name, NIC address and host name is indeed not guaranteed to be unique. The simplest way to make it unique is to add a serial number (I mean a real serial,number, such as 1, 2, 3 ... etc.). This has nothing to do with generating the alpha-numeric "key": the key is a function of the input only - if the input is not unique, the key cannot be unique either.

Link to comment
Share on other sites

The combination of name, NIC address and host name is indeed not guaranteed to be unique

 

In reference to the NIC address, I believe it is comprised of a MAC address that is issued by the IEEE, and is indeed unique.  Perhaps this has something to do with how FM deals with the NIC address now, can you clarify for me why the combination described is not in fact unique. 

Link to comment
Share on other sites

can you clarify for me why the combination described is not in fact unique. 

 

I believe you are correct: the NIC address is unique to the hardware. However, I don't know that there is only one license key issued per system. If that is so, then the name and the host name components are redundant, since - as you point out - the NIC is unique all by itself.

 

It's really difficult to figure out what the issue is here.

Link to comment
Share on other sites

The serial number I generate from the logica combination of name, nic, hostname is unique and has been setup to generate the same number when the user installs it in the same location, same compter and same name.  This is not the problem.

 

It will generate a 32 character serial number for me.  The user then supplies me with this number and requests a license key for activation of the product which I give him/her when they have paid.

 

As LaRetta has led me to a site for KeyCodeMaker.  The problem there is the same as I have in my code.  It generates a randamo Key and never consistent. 

 

The need for consistency is twofold.  1st there will be a script written into the solution based on the serial number to generate a Key which the user will never see.

 

2nd The user will email me registration details that include thwe serial number.  When I receive it I should be able to use the serial number and generate a key for him/her which is the same as the script in the solution.

 

I provide him with that key and when they type it in it will match the same field as in the solution.  On match, they will have registered and all is done.

 

For this reason do I need it to be consistent rather tahn random.

 

Keycodemaker is too expensive for what I wish to achieve and second it too is random.

Link to comment
Share on other sites

Well just to clarify, and its been awhile since I've used KeyCodeMaker, but it provides a decipher key as well which you would send to the User upon activation - just like you say you want, no?  Of course the code must be random on the outside but internally KeyCodeMaker knows so to IT, it is quite predictable.  If not random code it would be predictable and if predictable then it would be easy to break.  Or maybe I'm not understanding your need which is also quite possible.   :laugh2:

 

The cost is well worth it to many businesses who sell solutions but its not for everyone; nothing is.

Link to comment
Share on other sites

It will generate a 32 character serial number for me.

 

Do you mean a 32-digit numerical-only string? And you want to express this as a shorter alpha-numeric string? If so, why don't you simply convert it to a higher base? For example, you could use "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" as your alphabet to convert the number to base-36. See how here:

http://www.briandunning.com/cf/218

 

This is a straight one-to-one conversion, and you can very easily convert it back (and so can anyone who has read this thread....).

Link to comment
Share on other sites

Sure.......the cost for the intention and number of people I will seel the product to is high...this is relative to the number of people which will not be many at all.

 

Reagards predictability of the code and why I see no problem with it being consistent is that the user can only install it on his pc in his location.  If he installs it elsewhere or gives to someone else to install with the same key, it will not work because the NIC and hostname is different which in turn automatically generates a diccfferent serial number even if he users the same username.  Further he/she cannot use the same username as this is what will appear on his bills as a watermark and am sure that their client will not want that either.

 

So protections are  in place on that front. 

 

So all I need is to generate a key based on the serial number that is consistent and teh same when the same serial is entered.  if a different serial is entered then it should generate a different key.

Link to comment
Share on other sites

Comment,

 

Not a problem with people being able to convert back as the user can only install on his computer.  The registration will be in place to allow support to run from that period forth once I know it has been registered.

 

I tried the dec to base soltion you linked for me however what I seem to be getting is it generating only 2 alpha characters at most based on 3 numbers at most I entered on a field.  So if I use 4 numbers on a serial field then the dectobase field goes blank.  But 1 character will generate 9 alpha numeric.  Doesnt like more than 3 numbers for a serial.

Link to comment
Share on other sites

Comment....PERFECT, that is exactly what I was looking to try to understand.

 

You are a hero......Well all others that also helped me with this, but this works great.  Now I will be able to put in the '-' myslef in the result and have a magical key.

 

Thank you so much.

 

 

Thank you LaRetta as well for your input.

 

Yongzi

Link to comment
Share on other sites

:thumbsup:

 

... even though you flagged your own post as the correct answer instead of Comment's, LOL.  But everyone does that.  I use it as an example of how *NOT to design for a User.  

 

And welcome to FMForums!  

 

Added ... I think I would use script trigger upon ANSWER button click asking if they really solved their own problem or if they would like to select someone else instead.  

Link to comment
Share on other sites

This topic is 3853 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.