I am trying to use CRC for error checking for downloaded files.
I used NSURLConnection for downloading file.
But I have no idea where to start to use CRC for error checking.
Do I use some libraries? If so, would you recommend me one?
Can anyone tell me where I can find any examples or tutorials for CRC usage in c++ or objective c?
Thank you very much
First off, how is the file CRC handled on the server (if at all)? There are a multitude of algorithms (CRC32 for simple checksum, MD5/SHA for cryptographic hashes) which can be used, and you must use the same one. If the server does not provide any checksum information (say, from a checksum file), there is no use for a checksum as there is nothing to compare it to.
Related
I am building a Matlab application to be deployed as a compiled executable file.
This application will need to read/write files in a library.
These files contain data and I want to protect them from being read by whomever uses this application. Without any protection, these files would be saved as mat files and could be loaded into Matlab workspace.
I've tried to search for some solutions for encryption. I found some people suggesting AES, but this method seems to have an intrinsic problem of safely storing the encryption key (which I didn't understand exactly why).
Given that I simply want to avoid the user of the application to have access to those data files, what would be the best approach for doing so? If AES is actually a good solution, is it safe to write the encryption key in the code to be compiled?
It sounds like what you're looking for is functional encryption.
In functional encryption, a user holding
the master secret key msk can generate a function key skf
corresponding to a function f; then, anyone having a ciphertext Enc(x)
and a function key skf can compute f(x), but learns nothing else about
the input x.
Note that Enc(x) is the encrypted data and f(x) is some function of the unencrypted data.
Source: https://eprint.iacr.org/2013/229.pdf
Unfortunately, even cutting edge implementations of functional encryption are still impractically slow and not easily generalized to a MATLAB program.
When compiling an application, the MATLAB code files are encrypted; but not, as you’ve discovered, any extra files that you include.
If the data is not too large, consider saving it within a .m file rather than a .mat file. In other words, write a simple MATLAB function that returns your data, and has it hard-coded within the file. As this is now a code file, it will be encrypted as part of the compilation process.
You can even use the built in function matlab.io.saveVariablesToScript to auto-generate this file for you.
I would like, for educational purposes, to read PLC symbols table by using libnodave (or any equivalent open-source like snap7).
Actually, when I read data from merkers, I must know in advance what kind of variable will be present in the DB, also due to the fact that libnodave reads raw bytes in sequences.
I'm searching a way to know in advance what kind of data was chosen by the plc programmer when storing data so, when I use raw bytes read, I can easily monitor variables and adapt my reading and visualization routine.
Thanks in advance.
A program in a S7-3xx/4xx PLC has no symbolic addressing downloaded. So Libnodave or Snap7 can't point to a symbol.
TIA and the S7-12xx/15xx PLC are different. They have symbols downloaded. But so far as i know Libnodave or Snap7 can not use these symbols yet.
A solution maybe is the export the Symboltable is Step7/TIA to an Excel or .scv file and read there the symbol with it's format and address information.
(Libnodave does not support S7-12xx/15xx, use Snap7 instead.)
I'm doing a file sync application. for that I need to calculate both week and strong checksum for a file in client application and send it to the server. At the sever side, server needs to compare these checksum against a similar file (finding similar file is already implemented). I need week checksum to be 32 bit number and strong checksum to be 64 bit number.
I got rSync source code but I couldn't figure it out how it works.
If anyone familiar with these algorithm, please help me.
Thanks.
Refer to this: http://rsync.samba.org/tech_report/tech_report.html
It's pretty simple, and it is demonstrated in rsync's source code (see checksum.c).
I want to generate a MD5 hash of a text file in ABAP. I have not found any standard solution for generating it for a very big file. Function module CALCULATE_HASH_FOR_CHAR does not meet my requirements because it takes a string as an input parameter. Although it works for smaller files, in case of a for example 4 GB file one cannot construct such a big string.
Does anybody know whether there is a standard piece of coding for doing that (my google efforts did not bring me anything) or maybe someone has an MD5 algorithm in ABAP that calculates the hash of a file?
It looks like the implementation of this algorithm is impossible in ABAP because of the fact that the language does not allow arithmetic overflows during the calculations. This should also answer the question why it has not been implemented so far in SAP system. Either way looks that there is no other way as to call an external tool which of course is, regrettably, hardly platform independent.
EDIT: Ok! So with a great help of René and the code of Fast MD5 Implementation in Java I created the implementation of MD5 algorithm in ABAP . This implementation allows to update the calculated hash with more bytes, which of course might be coming from different sources.
There is no method which takes a file so far but anyways most of the work has been done.
Some simple ABAP Unit tests are included in the code, which also document how to use it.
Perhaps you could read the file in data blocks of a couple megabytes and create a hash list of those using the suggested function. And then create a single top hash using the generated hash list.
The SDN is usually a very good starting point for finding ABAP-related solutions. I was able to find this post: http://scn.sap.com/thread/1483479
The author suggests:
Upload the .txt file BUT as BIN.
Calculate the hash code using function MD5_CALCULATE_HASH_FOR_RAW
Are you able to get your file in binary format and use MD5_CALCULATE_HASH_FOR_RAW?
Edit: This post even has a more detailed answer using CALCULATE_HASH_FOR_RAW: http://scn.sap.com/thread/1298723
Quote of Shivanand Kalagi's answer:
STR_LEN = XSTRLEN( DATA ).
CALL FUNCTION 'CALCULATE_HASH_FOR_RAW'
EXPORTING
ALG = 'MD5'
DATA = DATA
LENGTH = STR_LEN
IMPORTING
HASH = L_MD5_HASH.
I am looking for checksum algorithm written in obj-c so that I can validate a ticket(number) and generate 2Dbar code based on validation.
Any ideas on how to achieve this?
Thanks
Sounds like you can use a public-key cryptographic function.
Encrypt with the private key fixed length information, including a number (the real ticket number) and a random salt (to reduce the chance of someone cracking your key), into a fixed length output.
You can then use the public key to decode that output and verify that the information is there.
Here is some Apple sample code that demonstrates the use of cryptographic functions.
For 2D barcode code, you could start by looking at ZXing