Page 1 of 1

file encryption

Posted: Sat Aug 14, 2010 2:38 pm
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.

Re: file encryption

Posted: Sun Aug 15, 2010 12:17 am
by arrielmabale
If it is from server to server communication, I think you can achieve this trough web services (SOAP in php).

Re: file encryption

Posted: Sun Aug 15, 2010 5:12 am
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.