checksum

To check if two image files are same..Checksum or Hash?

你离开我真会死。 提交于 2019-12-21 10:41:06
问题 I am doing some image processing code where in I download some images(as BufferedImage) from URLs and pass it on to a image processor. I want to avoid passing of the same image more than once to the image processor(as the image processing operation is of high cost). The URL end points of the images(if they are same images) may vary and hence I can prevent this by the URL. So I was planning to do a checksum or hash to identify if the code is encountering the same image again. For md5 I tried

Can anyone define the Windows PE Checksum Algorithm?

好久不见. 提交于 2019-12-21 04:39:22
问题 I would like to implement this in C# I have looked here: http://www.codeproject.com/KB/cpp/PEChecksum.aspx And am aware of the ImageHlp.dll MapFileAndCheckSum function. However, for various reasons, I would like to implement this myself. The best I have found is here: http://forum.sysinternals.com/optional-header-checksum-calculation_topic24214.html But, I don't understand the explanation. Can anyone clarify how the checksum is calculated? Thanks! Update I from the code example, I do not

What hash algorithms are parallelizable? Optimizing the hashing of large files utilizing on multi-core CPUs

爱⌒轻易说出口 提交于 2019-12-21 03:27:04
问题 I'm interested in optimizing the hashing of some large files (optimizing wall clock time). The I/O has been optimized well enough already and the I/O device (local SSD) is only tapped at about 25% of capacity, while one of the CPU cores is completely maxed-out. I have more cores available, and in the future will likely have even more cores. So far I've only been able to tap into more cores if I happen to need multiple hashes of the same file, say an MD5 AND a SHA256 at the same time. I can

What is the best way to calculate a checksum for a file that is on my machine?

北战南征 提交于 2019-12-20 07:58:27
问题 I'm on a Windows machine and I want to run a checksum on the MySQL distribution I just got. It looks like there are products to download, an unsupported Microsoft tool, and probably other options. I'm wondering if there is a consensus for the best tool to use. This may be a really easy question, I've just never run a checksum routine before. 回答1: Any MD5 will produce a good checksum to verify the file. Any of the files listed at the bottom of this page will work fine. http://en.wikipedia.org

Credit card number validator doesn't work correctly

爱⌒轻易说出口 提交于 2019-12-19 10:15:45
问题 def checksum(card_without_check): card_without_check = card_without_check[-1::-1] def numbers(string): return [int(x) for x in string] print(card_without_check) odd_numbers = numbers(card_without_check[0::2]) even_numbers = numbers(card_without_check[1::2]) odd_numbers = [x * 2 for x in odd_numbers] odd_numbers = [x - 9 if x > 9 else x for x in odd_numbers] print(even_numbers) print(odd_numbers) return sum(odd_numbers) + sum(even_numbers) def check(checksum, check): return checksum % 10 ==

Getting the CRC checksum of a byte array and adding it to that byte array

心不动则不痛 提交于 2019-12-18 15:48:38
问题 I have this byte array: static byte[] buf = new byte[] { (byte) 0x01, (byte) 0x04, (byte)0x00, (byte)0x01,(byte)0x00, (byte) 0x01}; Now, the CRC checksum of this byte array is supposed to be 0x60, 0x0A. I want the Java code to recreate this checksum, however I cant seem to recreate it. I have tried crc16: static int crc16(final byte[] buffer) { int crc = 0xFFFF; for (int j = 0; j < buffer.length ; j++) { crc = ((crc >>> 8) | (crc << 8) )& 0xffff; crc ^= (buffer[j] & 0xff);//byte to int, trunc

How do I check if a string is a valid md5 or sha1 checksum string

放肆的年华 提交于 2019-12-18 12:48:12
问题 I don't want to calculate a file's checksum, just to know if a given string is a valid checksum 回答1: SHA1 verifier: public boolean isValidSHA1(String s) { return s.matches("^[a-fA-F0-9]{40}$"); } MD5 verifier: public boolean isValidMD5(String s) { return s.matches("^[a-fA-F0-9]{32}$"); } 回答2: Any 160-bit sequence is a possible SHA1 hash. Any 128-bit sequence is a possible MD5 hash. If you're looking at the hex string representations of them, then a sha1 will look like 40 hexadecimal digits,

CRC16 checksum: HCS08 vs. Kermit vs. XMODEM

情到浓时终转凉″ 提交于 2019-12-18 12:36:25
问题 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? 回答1: you can implement 16 bit IBM, CCITT, XModem, Kermit, and CCITT 1D0F using the same basic code base.

Good choice for a lightweight checksum algorithm?

耗尽温柔 提交于 2019-12-18 12:21:58
问题 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

Implementation of Luhn Formula

╄→гoц情女王★ 提交于 2019-12-18 08:56:14
问题 I was trying to implement the Luhn Formula in Python, here is my code: import sys def luhn_check(number): if number.isdigit(): last_digit = int(str(number)[-1]) reverse_sequence = list(int(d) for d in str(int(number[-2::-1]))) for i in range(0, len(reverse_sequence), 2): reverse_sequence[i] *= 2 for i in range(len(reverse_sequence)): if reverse_sequence[i] > 9: reverse_sequence[i] -= 9 sum_of_digits = 0 for i in range(len(reverse_sequence)): sum_of_digits += reverse_sequence[i] result =