Unity Community |

Hi all,
I have a web player which I'd like to allow others to use - as long as they have a valid license file which I would issue to them.
I'd like my web player to
1) read the license file from the local folder
var www : WWW = new WWW (pathtolicensefile);
2) grab the text from the file
WWW.text
www.thisdomainname.com
licenseowner@domain.com
AFEJUTRDWS1KLA3QSCF3TG6JI24OLM5
3) check the current domain name and make sure it matches the domain in the license
WWW.url
4) Process an MD5 using the domain and email plus a few unknown vars e.g. domain+"//"+xtravars+"\\"+email and if the generated MD5 matches the (AFEJUTRDWS1KLA3QSCF3TG6JI24OLM5) MD5 from the file then we allow the web player to run - otherwise we throw a license error.
5) I'd also need an admin app for generating license files to send to clients.
I have done this sort of thing in other languages but not in javascript within Unity. Has anyone done this before and may be able to assist? Its a project for schools and I don't have much of a budget but I could certainly send a few PayPal dollars if someone could assist.
Thanks
JeffAU
Anyone happy to look at this one?
I do need it quite urgently and I can provide payment.
Infact, I can do most of it - just the MD5 javascripting would be a great help.
Thanks
Jeff
Google is realy good, you should try it someday :
http://pajhome.org.uk/crypt/md5/md5.html
Thanks appels - I tried Google and yes I agree it's quite a useful toolThe issue I have is one of time which is why I offered the old fashion trading method of payment for a person who is able to use tools such as Google and help with the script.
I think $50 to $100 would be a reasonable price - any thoughts of what this script should cost to create?
I'll keep this out there until next weekend - if no takers I'll do it myself
Seriously appels, thanks for the link - I'll certainly use that page for reference if I end up doing it myself next weekend - thanks.
If you are serious about security, _NEVER_ cheap out on it. This would take a couple minutes to crack. But it's a school project..in which case I hope it wasn't you that was meant to write itThanks appels - I tried Google and yes I agree it's quite a useful toolThe issue I have is one of time which is why I offered the old fashion trading method of payment for a person who is able to use tools such as Google and help with the script.
I think $50 to $100 would be a reasonable price - any thoughts of what this script should cost to create?
I'll keep this out there until next weekend - if no takers I'll do it myself
Seriously appels, thanks for the link - I'll certainly use that page for reference if I end up doing it myself next weekend - thanks.![]()
PM me here if you need anything.
Hy..This looked intresting and I am realy bored so I wrote a few lines on it
Code:
using UnityEngine; using System.Collections; using System.IO; { Valid, Invalid, LicenseNotFound, ErrorOcurred } public class licenseValidation { internal struct License { public string domain; public string email; public string md5; }; public string pathToLicense { get; set;} private string _domainValidUrl ; private state _validState; private bool _isDone=false; internal License license; public IEnumerator validateApp(bool checkDomain) { string phpDomain=""; yield return null; if(checkDomain) { yield return null; else checkDomain=false; } try { { string licenseRaw=www.text; string[] licenseInfo= licenseRaw.Split("/"[0]); license.domain=licenseInfo[0]; license.email=licenseInfo[1]; license.md5=licenseInfo[2]; { _validState = state.Invalid; } else { if(checkDomain) { if(phpDomain==license.domain) { if(Md5Sum("CryproService"+license.domain+"a46ls43"+license.email)==license.md5) { _validState = state.Valid; } } } else if(Md5Sum("CryproService"+license.domain+"a46ls43"+license.email)==license.md5) { _validState = state.Valid; } } } else { _validState=state.LicenseNotFound; } } catch { _validState = state.ErrorOcurred; } _isDone=true; } { int i=0; { urlRaw[i]=urlRaw[i].ToLower(); if(urlRaw[i].IndexOf("www")!=-1) return urlRaw[i]; } return ""; } internal string Md5Sum(string strToEncrypt) { System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding(); string hashstring = ""; { } return hashstring.PadLeft(32, '0'); } }
Simple Call Example
Code:
using UnityEngine; using System.Collections; { licenseValidation validation= new licenseValidation(); { } public IEnumerator waitForComplete () { { yield return null; } if(validation.validState==0) { //handle is Valid } else { //..... } } }
PHP Code to get domain of aplication nothing guarantees us that license and app are on same domain must call validateApp with "true" and set "domainValidUrl" before with path to where the php is hosted
Code:
<?php ?>
EDIT : Note the I havent tested this
Wow amazing work!!
Thanks so much for the time you have spent here.
Currently the php script would need to be placed somewhere on the server however a hard coded domain could be returned to match the license.
Could we simply parse www.url to get the domain of the server running the app?
Ok I'll start testing![]()
A big thanks for this. I'll be sure to pay you beyond what I have suggested above.
Cheers
Jeff
Hy Jeff
So when you use www.url it returns the url twaords you are pointing , so the URL to the license in our case as we are are loading the license file in that instruction..but nothing asures us that the hosting place of the app is same as we do not check it..So I wrote the php which returns us the url by the page which called the PHP , So in other words we check for domain of the app if it coincides with the one of the license and with the one specified in the license. Also you have to be the one hosting the php file.
Ah understood - so is there a function to simply get the domain which is currently hosting the app? The issue is that multiple schools would host this webplayer app on their websites. The app needs to be the same for all schools without any customisation other than providing each with a unique license file. Some may be running php, some asp or jsp etc.
So if our web player can internally check the domain which is used to run the app, grab the license locally (in the same folder where the app is located) and check that the domains match.
Ah possibly: Application.absoluteURL
http://unity3d.com/support/documenta...soluteURL.html
Hy Jeff..Yeah I reminded of that as well here are updated scipts they also tested this time they workalso with a editor scipt for createing the license files
Code:
using UnityEngine; using System.Collections; using System.IO; using System; public class licenseValidation { { Valid, Invalid, LicenseNotFound, ErrorOcurred, NotComplete } internal struct License { public string domain; public string email; public string md5; }; public string pathToLicense { get; set;} private bool _isDone=false; internal License license; public IEnumerator validateApp(bool checkDomain) { string absoluteDomain=""; yield return null; if(checkDomain) { } try { { string licenseRaw=www.text; string[] licenseInfo= licenseRaw.Split("#"[0]); license.domain=licenseInfo[0]; license.email=licenseInfo[1]; license.md5=licenseInfo[2]; license.domain.Replace(" ", ""); license.email=license.email.Substring(2); license.md5=license.md5.Substring(2,32); string localMd5= Md5Sum("CryproService"+license.domain+"a46ls43"+license.email); { _validState = state.Invalid; } else { if(checkDomain) { if(absoluteDomain==license.domain) { if(localMd5==license.md5) { _validState = state.Valid; } } } else if(localMd5==license.md5) { _validState = state.Valid; } else { _validState = state.Invalid; } } } else { _validState=state.LicenseNotFound; } } catch { _validState = state.ErrorOcurred; } _isDone=true; } { int i=0; { urlRaw[i]=urlRaw[i].ToLower(); if(urlRaw[i].IndexOf("www")!=-1) return urlRaw[i]; } return ""; } internal string Md5Sum(string strToEncrypt) { System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding(); string hashstring = ""; { } return hashstring.PadLeft(32, '0'); } }
Simple Call Test
Code:
using UnityEngine; using System.Collections; { licenseValidation validation= new licenseValidation(); { validation.pathToLicense=@"linkToLicense"; } public IEnumerator waitForComplete () { { yield return null; } if(validation.validState==0) { //handle is Valid } else { //..... } } }
Editor
Code:
using UnityEngine; using UnityEditor; using System.IO; { public string licenseName=""; public string licenseDomain=""; public string licenseEmail=""; public string licenseExtension=""; [MenuItem ("Window/License Editor")] static void Init () { } { { saveLicense(); } } public string Md5Sum(string strToEncrypt) { System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding(); string hashstring = ""; { } return hashstring.PadLeft(32, '0'); } public void saveLicense() { workingPath+="/Licenses/"+licenseName+"."+licenseExtension; StreamWriter sr= new StreamWriter(workingPath,true); sr.WriteLine(licenseDomain+"#"); sr.WriteLine(licenseEmail+"#"); sr.WriteLine(Md5Sum("CryproService"+licenseDomain+"a46ls43"+licenseEmail)); } }
Last edited by Bluee.Eyess; 05-14-2012 at 06:54 AM.
Wonderful work.
I'll run some tests now.
Please PM me with your PayPal email address and I'll send some funds.
Many thanks again.
JeffAU