Jump to content

rajoo.sharma

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by rajoo.sharma

  1. Hi, Is there any readily available solution for my requirement? I want a forum where users can post, then admin can shortlist from these posts, and then the shortlisted posts will be available for polling, in other words users can vote to select best x (lets say 10). Then these x posts will be available for discussion. After a period the conclusion can be displayed. I know there can not be exactly same solution, please suggest a closest match, an open source solution like phpBB (although I have never worked on it, thatz why I'm here ) and it should be easy to customize. Regards
  2. hello everyone, Could you please help me on calculating XOR checksum. The following works fine and gives me 0, which means the data is correct and we know by manually calculating it that it is correct. But I'm not able to implement it using a loop, as I really have no idea how long the value will be, it can be just 4 characters long or 100. Characters means hex values, a set of 2 each. so in a 4 characters long string we have 2 hex values i.e. a01e will be treated as a0 and 1e. Following works fine and gives me 0: function checksum($values){ $stra=substr($values, 0, 2); $strb=substr($values, 2, 2); $strc=substr($values, 4, 2); $strd=substr($values, 6, 2); $stre=substr($values, 8, 2); $strf=substr($values, 10, 2); $strg=substr($values, 12, 2); $strh=substr($values, 14, 2); $stri=substr($values, 16, 2); eval ("\$a = 0x$stra;\$b = 0x$strb;\$c = 0x$strc;\$d = 0x$strd;\$e = 0x$stre;\$f = 0x$strf;\$g = 0x$strg;\$h = 0x$strh;\$i = 0x$stri;"); echo $a^$b^$c^$d^$e^$f^$g^$h^$i; } $values="0191050902040843d1"; checksum($values); Following gives 2162888: function checksum($values){ $stra=substr($values, 0, 2); $i=2; while($i<strlen($values)) { $strb=substr($values, $i, 2); $i+=2; eval ("\$a = 0x$stra;\$b = 0x$strb;"); $c=$a^$b; $stra=$c; } echo $stra; } $values="0191050902040843d1"; checksum($values); Please Help Regards
  3. Hello, assigning a constant by prefixing 0x to a variable stores it as hex value, not as a string. $a=0xa1; //this 161 in decimal but if I already have a value somewhere, then how do I assign it same as above? $some_value = "a10ce2"; $a= substr($some_value, 0, 2); //this is not same as $a=0xa1; I've to use it for XOR checksum, I already have values in a text file, so I'll read a line and use XOR to validate. $a=0x87;$b=0xa0;$c=0x03;$d=0x00;$e=0x0c;$f=0x28; echo $a ^ $b ^ $c ^ $d ^ $e ^ $f; //perfectly returns 0; but this is a constant assigned to a variable, when we already have values: $values = "87a003000c28"; $a=substr($values, 0, 2); $b=substr($values, 2, 2); $c=substr($values, 4, 2); $d=substr($values, 6, 2); $e=substr($values, 8, 2); $f=substr($values, 10, 2); echo $a^$b^$c^$d^$e^$f; //does not return 0; Please help Regards
  4. Hello, I'm parsing a data frame and need to calculate the checksum for the data integrity. I understand the logic and can do it in ms-excel manually whether it is correct but I could not use it with ^ (XOR) operator in PHP. I've attached the excelsheet to make it obvious. Please Help implementing it. Regards [attachment deleted by admin]
×
×
  • 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.