checksum

Loading data for GCC's vector extensions

て烟熏妆下的殇ゞ 提交于 2019-11-30 13:44:08
GCC's vector extensions offer a nice, reasonably portable way of accessing some SIMD instructions on different hardware architectures without resorting to hardware specific intrinsics (or auto-vectorization). A real use case, is calculating a simple additive checksum. The one thing that isn't clear is how to safely load data into a vector. typedef char v16qi __attribute__ ((vector_size(16))); static uint8_t checksum(uint8_t *buf, size_t size) { assert(size%16 == 0); uint8_t sum = 0; vec16qi vec = {0}; for (size_t i=0; i<(size/16); i++) { // XXX: Yuck! Is there a better way? vec += *((v16qi*)

When generating a SHA256 / 512 hash, is there a minimum 'safe' amount of data to hash?

白昼怎懂夜的黑 提交于 2019-11-30 13:10:24
问题 I have heard that when creating a hash, it's possible that if small files or amounts of data are used, the resulting hash is more likely to suffer from a collision. If that is true, is there a minimum "safe" amount of data that should be used to ensure this doesn't happen? I guess the question could also be phrased as: What is the smallest amount of data that can be safely and securely hashed? 回答1: A hash function accepts inputs of arbitrary (or at least very high) length, and produces a

Fast open source checksum for small strings

五迷三道 提交于 2019-11-30 12:16:00
问题 I need a quick checksum (as fast as possilbe) for small strings (20-500 chars). I need the source code and that must be small! (about 100 LOC max) If it could generate strings in Base32/64. (or something similar) it would be perfect. Basically the checksums cannot use any "bad" chars.. you know.. the usual (){}[].,;:/+-\| etc Clarifications It could be strong/weak, that really doesn't matter since it is only for behind-the-scenes purposes. It need not contain all the data of the original

CRC16 checksum: HCS08 vs. Kermit vs. XMODEM

空扰寡人 提交于 2019-11-30 07:09:57
I'm trying to add CRC16 error detection to a Motorola HCS08 microcontroller application. My checksums don't match, though. One online CRC calculator provides both the result I see in my PC program and the result I see on the micro. It calls the micro's result "XModem" and the PC's result "Kermit." What is the difference between the way those two ancient protocols specify the use of CRC16? you can implement 16 bit IBM, CCITT, XModem, Kermit, and CCITT 1D0F using the same basic code base. see http://www.acooke.org/cute/16bitCRCAl0.html which uses code from http://www.barrgroup.com/Embedded

How to get the SHA-1/MD5 checksum of a file with Qt?

我的梦境 提交于 2019-11-30 06:51:50
问题 Is there a way to get the MD5 or SHA-1 checksum/hash of a file on disk in Qt? For example, I have the file path and I might need to verify that the contents of that file matches a certain hash value. 回答1: Open the file with QFile , and call readAll() to pull it's contents into a QByteArray . Then use that for the QCryptographicHash::hash(const QByteArray& data, Algorithm method) call. In Qt5 you can use addData() : // Returns empty QByteArray() on failure. QByteArray fileChecksum(const

Good choice for a lightweight checksum algorithm?

好久不见. 提交于 2019-11-30 06:51:45
I find myself needing to generate a checksum for a string of data, for consistency purposes. The broad idea is that the client can regenerate the checksum based on the payload it recieves and thus detect any corruption that took place in transit. I am vaguely aware that there are all kinds of mathematical principles behind this kind of thing, and that it's very easy for subtle errors to make the whole algorithm ineffective if you try to roll it yourself. So I'm looking for advice on a hashing/checksum algorithm with the following criteria: It will be generated by Javascript, so needs to be

Combining MD5 hash values

笑着哭i 提交于 2019-11-30 06:48:08
When calculating a single MD5 checksum on a large file, what technique is generally used to combine the various MD5 values into a single value? Do you just add them together? I'm not really interested in any particular language, library or API which will do this; rather I'm just interested in the technique behind it. Can someone explain how it is done? Given the following algorithm in pseudo-code: MD5Digest X for each file segment F MD5Digest Y = CalculateMD5(F) Combine(X,Y) But what exactly would Combine do? Does it add the two MD5 digests together, or what? In order to calculate MD5 values

When generating a SHA256 / 512 hash, is there a minimum 'safe' amount of data to hash?

本秂侑毒 提交于 2019-11-30 06:03:31
I have heard that when creating a hash, it's possible that if small files or amounts of data are used, the resulting hash is more likely to suffer from a collision. If that is true, is there a minimum "safe" amount of data that should be used to ensure this doesn't happen? I guess the question could also be phrased as: What is the smallest amount of data that can be safely and securely hashed? A hash function accepts inputs of arbitrary (or at least very high) length, and produces a fixed-length output. There are more possible inputs than possible outputs, so collisions must exist. The whole

Fast open source checksum for small strings

烈酒焚心 提交于 2019-11-30 01:48:12
I need a quick checksum (as fast as possilbe) for small strings (20-500 chars). I need the source code and that must be small! (about 100 LOC max) If it could generate strings in Base32/64. (or something similar) it would be perfect. Basically the checksums cannot use any "bad" chars.. you know.. the usual (){}[].,;:/+-\| etc Clarifications It could be strong/weak, that really doesn't matter since it is only for behind-the-scenes purposes. It need not contain all the data of the original string since I will be only doing comparison with generated checksums, I don't expect any sort of

Very slow to generate MD5 for large file using Java

微笑、不失礼 提交于 2019-11-30 00:53:49
I am using Java to generate the MD5 hash for some files. I need to generate one MD5 for several files with a total size of about 1 gigabyte. Here's my code: private String generateMD5(SequenceInputStream inputStream){ if(inputStream==null){ return null; } MessageDigest md; try { int read =0; byte[] buf = new byte[2048]; md = MessageDigest.getInstance("MD5"); while((read = inputStream.read(buf))>0){ md.update(buf,0,read); } byte[] hashValue = md.digest(); return new String(hashValue); } catch (NoSuchAlgorithmException e) { return null; } catch (IOException e) { return null; }finally{ try { if