how can I create a insert file input field, out put file field for the new file, license key field for generating up the license, also how to grant access to keys for ebooks and set it to a email and

cms1978
cms1978 used Ask the Experts™
on
how can I create a insert file input field, out put file field for the new file, license key field for generating up the license, also how to grant access to keys for ebooks and set it to a email and IP address?

how can I do this in visual basic or other software, I have visual basic 2008, and I heard about a web client to set this up for online activation for ebooks in exe and pdf format?

any ideas?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Here is a tutorial for password protecting a PDF with PHP.
http://www.idsecuritysuite.com/blog/password-protect-a-pdf-document-in-php

Generating licenses and emailing the password protected PDF is trivial, but I see you provided no example code for us to help with.

Mark BradyPrincipal Data Engineer

Commented:
I think this is way more than 1 question! You are expecting someone to show you how to do almost you entire application and yet you offer zero code or even a well formed question? I think you should think clearly about what you want to learn, then ask for help with one thing at a time. 1 question for each item you need help with is fair unless the thing you need help with is very trivial.

This is a php section so you won't get any help on writing this in anything but php scripting here. Visual basic is a completely different beast. But I'm not trying to put you off or not help you, just trying to steer you in the right direction to learn all this stuff.

To create a key (licence key) you could do it hundreds of ways and most of them very easy to do. It's a matter of choice for you and what level of security does it need to be. An un-hackable licence key (if there is such a thing) will take an awful lot of encrypting and coding. Heres a few simple ways you could do a licence key in PHP.

Say for Eg: we use the word "mypassword123" as the password. Not very strong for a password is it? But if we encrypt it, it will become much harder to decipher. A very simple way is to use hash algorithms like so:

$password = "mypassword123"; // unprotected password
$strong_password = MD5($password); // A 32 character long hash encryption of the password.
print($strong_password); // That will print out this:

9c87baa223f464954940f859bcf2e233

A 32 character long result. A lot of developers use this type of password to store inside a database instead of storing the actual password. The only problem is, it can't be reversed using any kind of mathmatical formula. It is possible to scan the many hash tables around the internet and try finding a match for it on one of those. Hash tables are basically a library of known words and password type words that the resulting MD5 hash or similar hash results. You type in the hashed password you have and it tries to find a match. If it does, it will return the word or phrase that created the hash and that will be your password. The simple password I used above is likely to be on one of those tables as no thought went into creating it.

But a password like "BH4P.twza!" would NEVER be found on any hash table. The chances are this would never be found so your hash of it would be totally secure.

So you can use a hash to create a licence key and maybe use a combination of the users email address and a random number, then hash the rsult. Something like:

$licence_key = MD5("someone@yoursite.com_".rand(10000,10000000));

That will return a hash of:

3fa220044ee4bfe807fb2fef1b89f063

you could even go further and append an underscore followed by the product name or id. Then to check if the password is correct, you take the password that was entered and do exactly the same process as we did to get the licence key, and if the two hashes match, the user has entered the correct licence code.

That was a basic one to give you an idea. You can create keys much longer than 32 characters and there are functions inside php that will do it for you.

Another simple one but effective is to base64_encode a security key like this.

$key = "1234-5678-9876-5432-1212";

$licence_key = base64_encode($key);
print $licence_key;

That will print out this:

MTIzNC01Njc4LTk4NzYtNTQzMi0xMjEy

That can simply be decoded by the following command

print base64_decode($licence_key);

That will print out your original key. Once again that is not very secure as it is easy for any php person to decode but it gives you an idea on perhaps how to get started making a licence key for your products. I hope this has been some help.

Author

Commented:
elvin66: wow thanks, you are an expert, do I need to run that kind of software in my cpanel md5 code? I dont think I can just use an md5 hash without the engine installed?

thanks I can use this and try to implement this with a vb script for creating a software, unless php can actually make a desktop type of software?
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

Mark BradyPrincipal Data Engineer

Commented:
Well you can't actually create a stand alone software with php as it is a scripting language and needs a web browser and a php enabled server to run the scripts. Php can do anything other desktop software can do like file creating and manipulation but if you are looking for desktop software then VB or even better (in my opinion) is DElphi. Delphi is a windows programming program for writing your own software.

If you have a website uploaded onto your hosting server, most servers these days have php installed so you can do a lot with php. The MD5 hash works on most software programs and scripting languages but to do what I suggested you would need to upload the php page/script onto your server then when you access/navigate to that page (ie: www.yoursite.com/yourPhpPage.php) the code in the script will run.

So if you were to save this code below in a text file and named it "hash.php" then ran it on a server, the result would be this (in your web browser);

Hello, my name is Mark and my licence key is MTIzNC01Njc4LTk4NzYtNTQzMi0xMjEy

Here is the code to do that:

<?php
$key = "1234-5678-9876-5432-1212";

$licence_key = base64_encode($key);
$myname = "Mark";

echo "Hello, my name is " . $myname . " and my licence key is " . $licence_key;

?>

That little bit of code would produce the result I typed above. Pretty simple. I would suggest if you had the interest and the spare time to learn a bit of php as it is one of the easiest languages to learn and you may be exactly what you need. Thanks for the comments by the way!

Author

Commented:
thank you, I am learning php and the above code does work, how can I get vb script to communicate with the php website?

do you call each variable as in $myname and $license_key to the vb software script with a var that vb script uses? that way the software and website can register usernames and keys? I don't know exactly how a license key can be inserted into a software for protection and it will also be registered in my users account on the website?

do I need a web client server to access my vb script? and does it call a php $variable in the database to a variable in a vb script software and how?

if you can help please
Principal Data Engineer
Commented:
I know zero about VB script/coding. I do know the process it should all take though. Something like this.

Your vb program will look for an internet connection when it is installed. If it finds one it goes to your website and searches the database for the serial number of that particular piece of software (you give them all different serial numbers - I'll explain how later). What you do is have a php page that excepts a serial number by way of the "GET" method (in the url). Then after doing some checks to make sure it is the right type of information it will create a registration key based on the serial number you feed it through the vb program. Then it will register the software so it will run on that pc only. You don't have to be that strict but I always do this. Once a licence has been purchased, your program will be able to return a few key items. 1: The hard drive serial number on the computer. 2: The ram serial. 3: The motherboard serial.

That is plenty enough info. You register all 3 of those numbers under the one registration. The licence key is entered into the program via the registry probably if it is a windows app. Now each time your program runs it will check that it is registered via reading the value in the registry key. If it finds the registration and it checks out, then all is good but if the program is copied to another computer or hard drive it will fail the check. I make my programs look for the internet connection each time it runs to 1: check the registration info is correct and 2: Download and update any new files for software updates. That way you can keep the software up to date and the program updates itself when there is a connection.

That's about the gist of it. I can't tell you how to write the vb code as I have never used it but the php part is easy for me to write so I would be happy to help you with that side of it.

Do you know how to setup a database and add/edit tables in mysql ? If so then half the battle is won already.

You will need to get the program sorted out then let me know and I will write a script that your program accesses. Fair enough?
Mark BradyPrincipal Data Engineer

Commented:
Here is a VB code function I found that retrieves data from any web page. All you do is feed it the URL and it will return whatever is on that page. The function:

Public Function GetPageHTML( _
           ByVal URL As String) As String
  ' Retrieves the HTML from the specified URL
  Dim objWC As New System.Net.WebClient()
  Return New System.Text.UTF8Encoding().GetString( _
     objWC.DownloadData(URL))
End Function

and how to use it:

getLicence = _
   GetPageHTML("http://www.yoursite.com/licencing/check.php?hd=WD123-567-890")


What that does is firstly it will go to the URL we specify. I appended the URL with the (fake) hard drive serial number so you would need your program to return this information before you run the licence check. The php script will take the hard drive number, and look up that number in the registration table. If it finds it it will return "REGISTERED" and if it can't find it you will be returned "UNREGISTERED"

If the result is UNREGISTERED you can then look at the time period if you have a 30 day try before you buy licence. In any case, I think you will see what I have done here. Feed the URL with a certain link depending on what we name our php script. Get back information on the software being licensed or not. Then you can act accordingly but either shutting down the program if it is not licenced or opening the registration webpage or something like that.

Hope this helps you out somewhat.

Author

Commented:
thanks elvin66

I have a script to try to fix, I have some basic understanding of php and mysql

I want to fix this protection script, I should fix this script and make a new protection software for this script.

cry1978@gmail.com....is my email


Author

Commented:
Public Function GetPageHTML( _
           ByVal URL As String) As String
  ' Retrieves the HTML from the specified URL
  Dim objWC As New System.Net.WebClient()
  Return New System.Text.UTF8Encoding().GetString( _
     objWC.DownloadData(URL))
End Function



don't know how to use this in visual basic, I'm new to vb? what app does it go into, or what kind of vb window, like windows form, WPF Browser, Console? I'm using vb 2008

however, I have dug into my project a bit and see that they actually license the products with php code on the website and link it some how to communicate with the visual basic software that they run with this website, I think its visual basic. I have the source codes for the actual software, I can tell you the file types it has.

 exe source code pic

Author

Commented:
this software exe in my website has a runtime 5 error it it though, the script says it will not work unless you install it with the installer file, the insall file sets up the database, user admin and so on, like a normal script installs.

is this TRUE???? or are they just making up excuses for why there product does not work? to me it does not make any since?

maybe I should just try to make the software end myself, I have a membership to a website that is running the same exact website and software system, I have designed the lock of the app but need to fill in the guts lol

basically, its just a windows form that I created with 2 textboxes for users to input there AccID and ProdID, these are variables that php uses and it is called by vb.exe software or something, and below that is a insert file option and a output file location.

so they put in there account ID and Product ID that is in there profiles, next they find there ebook they want to protect and then output it to a location WHERE they want the file in there pc.

When they open this file, that is an ebook.exe file now, they will get a screen for them to insert a license key or continue to a trial before they buy, if they want to buy it will be taken to my clients website to buy the product.

this is how it is setup, can anyone help my demo project for creation
Mark BradyPrincipal Data Engineer

Commented:
I'm afraid I'm no help at all when it comes to VB software. I use to program using Delphi but now I am a Php developer. I looked around on Google and found that VB function I posted earlier but I don't know where it would go. Probably into a program that is compiled in VB. Sorry I can't help you further with it. Perhaps asking the right question in the VB section might help. Good luck.

Author

Commented:
ok thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial