binaryfiles

Placing an image in an object, sending the object over rpc and then using hibernate

青春壹個敷衍的年華 提交于 2019-12-12 03:41:19
问题 I am using gwt rpc and hibernate on the back end. I have an object in which one of the field is an image. I have to place the image in the object, send the file over rpc and saving it back to database using hibernate. Does anyone of you have an idea about this?? 回答1: It can't be done exactly as described. In javascript, you can't capture the binary contents of a file into the javascript VM. You have to use file upload to send it to the server. Your flow needs to be something like: Capture non

what is iteration count and byte count in hexdump?

萝らか妹 提交于 2019-12-12 03:38:22
问题 It was really confusing to deal with hexdump command in linux. Basically I am trying to get the output from the /proc/device-tree. I tried to use the hexdump but ended up with confusion. My dts contains vvn = <0 0 2 2 0 0>; I got a proc node under /proc/device-tree. I tried the following command. hexdump -v -e '4/1 "%x" " "' vvn ; echo 0000 0000 0002 0002 0000 0000 hexdump -v -e '1/4 "%x" " "' vvn ; echo 0 0 2000000 2000000 0 0 hexdump -v -e '4/1 "%x "' vvn ; echo 0 0 0 00 0 0 00 0 0 20 0 0

read string from file and turn into bitset<12>

十年热恋 提交于 2019-12-12 02:25:04
问题 Hi I'm trying to read string from txt file and transform it into binary file which is bitset<12> string form. int main() { using namespace std; std::ifstream f("fruit.txt"); std::ofstream out("result.txt"); std::hash<std::string>hash_fn; int words_in_file = 0; std::string str; while (f >> str){ ++words_in_file; std::bitset<12>* bin_str = new std::bitset<12>[3000]; int temp_hash[sizeof(f)]; std::size_t str_hash = hash_fn(str); temp_hash[words_in_file] = (unsigned int)str_hash; bin_str[words_in

reading binary from a file gives negative number

南楼画角 提交于 2019-12-12 02:21:55
问题 Hey everyone this may turn out to be a simple stupid question, but one that has been giving me headaches for a while now. I'm reading data from a Named Binary Tag file, and the code is working except when I try to read big-endian numbers. The code that gets an integer looks like this: long NBTTypes::getInteger(istream &in, int num_bytes, bool isBigEndian) { long result = 0; char buff[8]; //get bytes readData(in, buff, num_bytes, isBigEndian); //convert to integer cout <<"Converting bytes to

How to read and write tar file in C?

家住魔仙堡 提交于 2019-12-12 01:55:26
问题 I want to read the tar file and write it to another tar file using C. The procedure what I m following here is : Creating a tar file of the folder Writing client socket program for reading that tar file as binary file in C using fread function Writing whatever comes in buffer to socket Writing server socket program to receive sent data into a buffer Writing the received buffer into the another tar file. Closing files and socket. Here is code : Server.c #include <stdio.h> #include <stdlib.h>

Creating 16 and 24-bit integers from binary file

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 01:29:35
问题 I'm modifying an existing Python app that reads a binary file. The format of the file is changing a bit. Currently, one field is defined as bytes 35-36 of the record. The specs also state that "...fields in the records will be character fields written in ASCII." Here's what the current working code looks like: def to_i16( word ): xx = struct.unpack( '2c', word ) xx = ( ord( xx[ 0 ] ) << 8 ) + ord( xx[ 1 ] ) return xx val = to_i16( reg[ 34:36 ] ) But that field is being redefined as a bytes 35

What is the fastest way to read a specific chunk of data from a large Binary file in Python

妖精的绣舞 提交于 2019-12-11 21:54:42
问题 I have a sensor unit which generates data in large binary files. File sizes can run into several tens of Gigabytes. I need to: Read the data. Process it to extract the necessary information that I want. Display / Visualize the data. Data in the binary file is formatted as: Single precision float i.e. numpy.float32 I have written the code which is working well. I am now looking to optimize it for time. I observe that it is taking a very large time to read the binary data. The following is what

What is the meaning of `16 longs` and `110 words`, when reads the bits from a file

微笑、不失礼 提交于 2019-12-11 18:08:02
问题 I'm trying to read PUD file format, that belong to the warcraft 2 game map. In the explanation of file structure, there is small phrases I don't understand it. What is this mean ( 16 longs , 110 words ) ? Here is an example 16 longs -------> Units and buildings allowed. (16 players) units bit order: 0000000000000000000000000000000x bit0: footman/grunt 000000000000000000000000000000x0 bit1: peasant/peon 00000000000000000000000000000x00 bit2: ballista/catapult 0000000000000000000000000000x000

calculate hash of binary file containing certain bytes

醉酒当歌 提交于 2019-12-11 17:43:47
问题 I'm having trouble understanding the principle/method, on how to "manually" calculate a file's hash (sha256) which consist of certain bytes. To put into an example: I have this binary file consisting of these bytes. 2C F2 BA A3 0E 26 5A 3B 2A 1F 01 4A 01 66 60 02 How to get following (correct) hash of the file? ea3cbd30dc6c18914d2cdafdd8bec0ff4ce5995c7b484cce3237900336abb574 回答1: 1. Convert all bytes to ASCII. 2. Hash ASCII string to get correct hash from the file. Doing this manually is not

Encryption and decryption binary files with c#

試著忘記壹切 提交于 2019-12-11 17:17:27
问题 There are lot of examples of encrypting/decrypting passwords and simple text files with c#, available on web. But I havn't found any example on encrypting or decrypting entire binary file like .exe or .mdb file. Can anybody provide an example on encrypting/decrypting binary file or can provide some links. Thanks for sharing your valuable time. 回答1: It's pretty much the same, since the Crypto-APIs deal anyway always with byte streams or arrays. This might help you: http://www.codeproject.com