file encryption

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

file encryption

Post by nite4000 »

Hey all

I was wondering if there is a way to ready a file that has been encrypted using crypt()

I created a file from php code called license.lbi

and in teh code that create the file i have crypt($site_url);

$site_url = http://www.mydomain.com

now when the file is created its encrypted now is there a way to chk the created file for the url like if i was at mydomain.com and when it chks the file it will see it matches and do nothing but if i was trying to use the script one another domain then what is in the license file it would come up with a error.

I just need to know if there is a way to do this or should i try this another way.
User avatar
arrielmabale
Forum Newbie
Posts: 15
Joined: Fri Aug 13, 2010 3:57 pm
Location: Dubai

Re: file encryption

Post by arrielmabale »

If it is from server to server communication, I think you can achieve this trough web services (SOAP in php).
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: file encryption

Post by requinix »

nite4000 wrote:I was wondering if there is a way to ready a file that has been encrypted using crypt()
Taking your words at face-value: no. You can't. It even says so right on the manual page:
Note: There is no decrypt function, since crypt() uses a one-way algorithm.
Why? crypt() is not encryption. It is hashing, just like md5() and sha1().

Putting that aside, with the default DES-based hashing algorithm only the first 8 characters in the input are used. Everything else is ignored. That means hashing "http://www.mydomain.com" and "http://wASKLDJHASKLDJHAS" will produce the same output given the same salt. You can fix this by providing your own salt generated according to the rules for one of the other support algorithms.
Post Reply