checksum

Checksum of SELECT results in MySQL

余生颓废 提交于 2019-12-01 09:44:01
问题 Trying to get a check sum of results of a SELECT statement, tried this SELECT sum(crc32(column_one)) FROM database.table; Which worked, but this did not work: SELECT CONCAT(sum(crc32(column_one)),sum(crc32(column_two))) FROM database.table; Open to suggestions, main idea is to get a valid checksum for the SUM of the results of rows and columns from a SELECT statement. 回答1: The problem is that CONCAT and SUM are not compatible in this format. CONCAT is designed to run once per row in your

Problem in calculating checksum : casting int to signed int32

坚强是说给别人听的谎言 提交于 2019-12-01 07:52:53
问题 I need to convert the following c code (to calculate checksum for a file) to python. I had written, the corresponding code in python but the result didn't match the c version. The problem was that python autmatically promotes int to long whenever overflow occurs and this results in wrong checksums. Any idea how to overcome this problem ? or is there a python function that converts long to signed int32 ? Thanks int calcChecksum(const guchar *data, gsize len) { const guchar *p = data; int

Python 2.7: Compressing data with the XZ format using the “lzma” module

落花浮王杯 提交于 2019-12-01 05:48:51
I'm experimenting with the lzma module in Python 2.7.6 to see if I could create compressed files using the XZ format for a future project that will make use of it. My code used during the experiment was: import lzma as xz in_file = open('/home/ki2ne/Desktop/song.wav', 'rb') input_data = in_file.read() compressed_data = xz.compress(input_data) out_file = open('/home/ki2ne/Desktop/song.wav.xz', 'wb') in_file.close() out_file.close() and I noticed there were two different checksums (MD5 and SHA256) from the resulting file compared to when I used the plain xz (although I could decompress fine with

Python 2.7: Compressing data with the XZ format using the “lzma” module

一曲冷凌霜 提交于 2019-12-01 03:04:13
问题 I'm experimenting with the lzma module in Python 2.7.6 to see if I could create compressed files using the XZ format for a future project that will make use of it. My code used during the experiment was: import lzma as xz in_file = open('/home/ki2ne/Desktop/song.wav', 'rb') input_data = in_file.read() compressed_data = xz.compress(input_data) out_file = open('/home/ki2ne/Desktop/song.wav.xz', 'wb') in_file.close() out_file.close() and I noticed there were two different checksums (MD5 and

Compact way of getting file checksum in Perl

家住魔仙堡 提交于 2019-12-01 02:54:30
问题 I am looking for ways to get file checksums in Perl but not by executing the system command cksum -- would like to do it in Perl itself because the script needs to be portable between UNIX and Windows. cksum <FILENAME> | awk '{ print $1 }' works on UNIX but obviously not in Windows. I have explored MD5 but it seems like getting a file handle is necessary and generally it doesn't seem like a very compact way to get that data (one-liner preferable). Is there a better way? 回答1: Here are three

Compiling Twice with Delphi 6 and getting the same checksum on the binary

你离开我真会死。 提交于 2019-11-30 21:40:31
For the purposes of binary / source code verification, i'd like to be able to make two compiles on the same computer 2 weeks apart and have the binaries be identical and thus pass some checksum test. So far I've found that most likely the timestamp will be written by the compiler into the binary. I can work around this by doing the compare on the dumpbin /rawdata results per this msdn article. http://support.microsoft.com/kb/164151 However the dumpbin results still differ in a about a dozen places and the difference still appears to be some kind of timestamp (changing from A1 73 to C4 76) for

Calculate file checksum in FTP server using Apache FtpClient

£可爱£侵袭症+ 提交于 2019-11-30 18:00:43
问题 I am using FtpClient of Apache Commons Net to upload videos to FTP server. To check if the file has really been successfully transferred, I want to calculate the checksum of remote file, but unfortunately I found there is no related API I could use. My question is: Whether there is a need to calculate file checksum in ftp server? If the answer is yes, how to get checksum in FtpClient? If the answer is no, how do FtpClient know if the file has really been successfully and completely

Compiling Twice with Delphi 6 and getting the same checksum on the binary

时间秒杀一切 提交于 2019-11-30 17:35:07
问题 For the purposes of binary / source code verification, i'd like to be able to make two compiles on the same computer 2 weeks apart and have the binaries be identical and thus pass some checksum test. So far I've found that most likely the timestamp will be written by the compiler into the binary. I can work around this by doing the compare on the dumpbin /rawdata results per this msdn article. http://support.microsoft.com/kb/164151 However the dumpbin results still differ in a about a dozen

Calculate multiple checksums from the same InputStream using DigestInputStream

三世轮回 提交于 2019-11-30 16:04:06
I am trying to figure out how to read multiple digests (md5, sha1, gpg) based on the same InputStream using DigestInputStream . From what I've checked in the documentation, it seems to be possible by cloning the digest. Could somebody please illustrate this? I don't want to be re-reading the stream in order to calculate the checksums. Louis Wasserman You could wrap a DigestInputStream around a DigestInputStream and so on recursively: DigestInputStream shaStream = new DigestInputStream( inStream, MessageDigest.getInstance("SHA-1")); DigestInputStream md5Stream = new DigestInputStream( shaStream

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

六月ゝ 毕业季﹏ 提交于 2019-11-30 13:48:52
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 sign crc ^= ((crc & 0xff) >> 4); crc ^= (crc << 12) & 0xffff; crc ^= ((crc & 0xFF) << 5) & 0xffff; }