Comments (5)
I added an example in the last commit today.
Best regards, Anthony.
from crcphp.
thank you very much for your time and help you are great! I will test it.
from crcphp.
Sorry to disturb you again, the example works fine but i want to use it inside a class and i can't get it working i tried 3 days to sort this, can you help me? I want to pay you. thanks, this is the code, i think must call inside a class? I want to retrieve some bytes (string) from a uploaded bin file and calculate the cs of it. I don't have php expenrience but with some exampe codes it will help me a lot. thanks again!
`<?php
require_once "../utils.php";
include "../crcphp/crc8.php";
class test {
public function read_only(){
return false;
}
public function accept_size($size){
return $size == 2048;
}
public function get_data($data){
$crc8 = new Crc8();
$algoParams = $CRC_8_;
$algoName = $algoParams->Name;
echo "Name: ".$algoName."<br/>";
$check = $algoParams->Check;
print "Check: 0x".dechex($check)."<br/>";
$test = ((ord($data[0x02]) & 0xFF) << 16)
+ ((ord($data[0x01]) & 0xFF) << 8)
+ ((ord($data[0x00]) & 0xFF) );
$test = intval($test);
$array = array();
$array['TEST'] =round($test);
return $array;
}
public function set_test($data, $test2){
if (isset($_POST['swap2'])) {
$data = swap($data);
} else {
;
}
if($test2 < 0){
$test2 = 0;
} else if ($test2 > 999999){
$test2 = 999999;
}
for($n = 0x00; $n < 0x80; $n+=16){
$data[$n+0] = chr(($test2) & 0xFF);
$data[$n+1] = chr(($test2 >> 8) & 0xFF);
$data[$n+2] = chr($test2 >>16 & 0xFF);
}
if (isset($_POST['swap2'])) {
$data = swap($data);
} else {
;
}
return $data;
}
}
?>
`
from crcphp.
It's not good practice, but you can use it as a global variable.
$algoParams = $GLOBALS['CRC_8_'];
from crcphp.
It's not good practice, but you can use it as a global variable.
$algoParams = $GLOBALS['CRC_8_'];
https://stackoverflow.com/questions/1877136/access-global-variable-from-within-a-class
from crcphp.
Related Issues (7)
- Wrong check value or algorithm HOT 1
- Issue calculating CRC-16/MCRF4XX HOT 1
- How to use crc16? HOT 2
- [CRC-CCITT (Kermit)] Inverted Bytes? HOT 1
- example? HOT 1
- Do you have any example? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crcphp.