Hi,

I want to crypt a date and time $exp=crypt("2004-12-31 23:59:59") then crypt the current date and time.

Then if($currentdate < $exp) then "ok" else "error".
Is it possible to create something like that?

One more questio, is it possible to crypt a php code?

example:
crypt("
$test="Hello World!";
echo"$test";
")

    you wont be able to do the if statement because the date information is encrypted, and the comparison wont be comparing dates, it will only be comparing the ascii values of the script.

    you could encrypt php code like
    $data = crypt("$test=\"Hello World!\";
    echo\"$test\";");
    but there wont be any way to get the data back, or any way to execute it.

      If you crypt it, the string will change ... it may result in different values, example ::

      echo md5(04-08-31 12:16).'<br>'.md5(04-08-31 12:13);

      you'll see that 12:16's string is less than 12:13's string!

      why do you want to crypt them anyways? maybe I can help out using a better way...

      Source made during test ::

      <?php
      $exp=date("y-m-31 h:i");
      //$exp=date("y-m-31 h:i:s");
      echo 'Current date & time :: '.$exp.'<br>';
      echo 'Crypted date & time :: '.md5($exp).'<br>';
      $crypCurDate=md5($currentDate);
      echo $crypCurDate.'<br>';

      if ($crypCurDate < $exp) echo 'correct';
      else echo 'false';
      ?>
      <form action="<?php echo $PHP_SELF;?>" method="post">
      <input type="text" name="currentDate">
      <input type="submit" value="TesT">
      </form>

        I want to make some kind of license system for the support.
        They may download 4 free the php administration made specialy for windows networks.

        And the if they want support, they have to buy a license.
        That's why i can to crypt the date, then send them a file called key.php and the every time a php page is opened it checks the current date, and checks if the date is smaller then the crypted date.

          I dont recommend you use that method, since encryption using PHP's built in functions results in non-sorted values.

          By that I mean that it's not necessary for a value bigger than another to have a bigger value as an encrypted string. (see the example in the above post).

          I suggest you create a file/sql table and store their names/emails in it.

          You can store the md5 value since it doesn't change, i.e., static for the same string.

          example :: if you'd like to encrypt 'k' -> 8ce4b16b22b58894aa86c421e8759df3

          ofcourse, I dont recommend just encrypting an email, try adding the id to it like this :: $cryptMe=md5($ID.someone@email.com);

          If you'd like a secure portal system, go to www.hotscripts.com and search there, they have many free & commercial ones... if you're to sell things online, make you use SSL (https).

          Hope that helps.

            if you want to build in time expiring licenses, you should look at the zend encoder. it encodes php code so it cannot be stolen and you can also build in checks that only allow it to run on a certain server, and expire at a certain date. the code is irreversible and the zend software was written by the same people who wrote the zend engine in the php language. it does cost money, but if you are developing a serious program that you dont want to get pirated and have the date checks hacked, you should use this.
            even if you do write a function to encode dates and compare them, anyone who knows php could look at the code and remove all the checks and make the program work.
            http://www.zend.com/store/products/zend-encoder.php?home

              Write a Reply...