Jump to content

Encryption / Decryption Using Bitwise function


RichI

Recommended Posts

Hello,

 

I am very new to PHP, and I am trying to create a function that will create a set of 2 hex codes to decrypt matching codes.  I can not seem to get it to work it just returns all zeros.  If anyone can help I would be greatful.  Here is the code as I have come up with so far.

 

This has a few of my revisions in it so you can see some of what I have attempted.

 

 

<?php

function DLStatusEncode($Val1, $Val2)

{

 

  $key=array(10101101000110101010111100100101,1010110101111111001000101011001,1010101101110111100010010,10001101111010010000111000010110);

//$key = array();

//$key[1] ='10101101000110101010111100100101';

// $key[2] = '1010110101111111001000101011001';

// $key[3] = '1010101101110111100010010';

// $key[4] = '$10001101111010010000111000010110';

 

  //$key[1] ='$AD1AAF25';

// $key[2] = '$56BF9159';

// $key[3] = '$0156EF12';

// $key[4] = '$8DE90E16';

 

  $sum = 0;

  $delta = 10011110001101110111100110111001;

  $sn_low = decbin($Val1);

  $sn_high = decbin($Val2);

 

// print "$sn_low" . "\n";

// print "$sn_high". "\n";

// print "$key[0]". "\n";

  $sn_low==($sn_low>>1);

// $test = $sn_low ^ $key[0];

  print "$sn_low"."\n\n\n";

 

$n = 1;

  while ($n <= 31):

  print $sum;

    $sum == $sum + $delta;

    $sn_low == $sn_low + ((($sn_high << 4) + $key[0]) ^ ($sn_high + $sum)

    ^ (($sn_high >> 5) + $key[1]));

 

    $sn_high == $sn_high + ((($sn_low << 4) + $key[2]) ^ ($sn_low + $sum)

    ^ (($sn_low >> 5) + $key[3]));

      $n++;

  endwhile;

 

  $cod1 == bin2hex($sn_low);

  $cod2 == bin2hex($sn_high);

 

  echo "$cod1";

  echo "$cod2";

  }

 

 

 

$val1 ="23454";

$val2 = "0";

echo "$val1";

echo "$val2";

 

DLStatusEncode($val1,$val2)

 

 

?>

 

Thanks for the Help

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.