byte

Read bytes from a binary file with JavaScript, without jQuery

守給你的承諾、 提交于 2019-12-07 12:16:33
问题 I'm trying to make a javascript emulator, and i'd like it to be very light, so I don't want to load the "ROMs" with jQuery and jDataView. Si I made my own ROM loader in pure JS. It works pretty well (thanks to many topics on this site), but there's still a problem on IE, for which I couldn't find any help elsewhere. Here's my JS code: /** * @param file - the path or URL of the ROM file to load. The file must be served with the Mime-Type: 'text/plain; charset=x-user-defined' * @param callback

c# How to Continuously find a byte array inside a byte array?

家住魔仙堡 提交于 2019-12-07 11:53:52
问题 I'm trying to continuously find a byte array (byte[]) within a byte array and I found a code that only finds the first occurrence. This is where I found the code: Find an array (byte[]) inside another array? Question: How can I continuously find a byte array with this code below? public int SearchBytes(byte[] haystack, byte[] needle) { int len = needle.Length; int limit = haystack.Length - len; for (int i = 0; i <= limit; i++) { int k = 0; for (; k < len; k++) { if (needle[k] != haystack[i +

Clear Datagram Buffer in Java

馋奶兔 提交于 2019-12-07 11:36:32
问题 So I got this simple udp client/server code from the internet, and it works. However, when I enter something that is shorter than the thing I entered before it, I get the remaining characters left over. For example, if I first enter: kitty And then enter: cat The second print reads as: catty I've been looking at other people with similar problems and most of them seem to be solved by clearing the byte array. However, if I try to implement their answers, it doesn't fix my problem. What do I

Converting from 8 bits to 1 byte

不想你离开。 提交于 2019-12-07 09:23:29
问题 I have a string of 8 bits and I want to convert it into 1 byte. I am not sure why my function is not working properly. I have 8 bits stored into an array of 8 unsigned chars. This is my method so far: unsigned int bitsToBytes(unsigned char *bits) { unsigned int sum = 0; for(int i = 7; i >= 0; i--) { sum += bits[i]; sum<<=1; } return sum; } int main() { unsigned char bits[8]; unsigned int byt; byt = bitsToBytes(bits); cout << byt; //doesn't give me the right result } EDIT: My array of bits

How to perform unpadding after decryption of stream using CryptoPP

纵然是瞬间 提交于 2019-12-07 09:17:25
I've got the stream to decrypt. I divide it into blocks and pass each block to the method below. The data I need to decrypt is encrypted by 16 - bytes blocks and if the last block is less than 16, then all the rest bytes are filled by padding. Then in the moment of decryption I'm getting my last block result as the value including these additional padding bytes. How can I determine the length of original data and return only it or determine the padding bytes and remove them, considering different paddings could be used? void SymmetricAlgorithm::Decrypt(byte* buffer, size_t dataBytesSize) {

Convert arbitrary size of byte[] to BigInteger[] and then safely convert back to exactly the same byte[], any clues?

对着背影说爱祢 提交于 2019-12-07 08:15:09
问题 I believe conversion exactly to BigInteger[] would be optimal in my case. Anyone had done or found this written in Java and willing to share? So imagine I have arbitrary size byte[] = {0xff,0x3e,0x12,0x45,0x1d,0x11,0x2a,0x80,0x81,0x45,0x1d,0x11,0x2a,0x80,0x81} How do I convert it to array of BigInteger's and then be able to recover it back the original byte array safely? ty in advance. 回答1: Use BigInteger.toByteArray() and BigInteger(byte[]). According to the javadoc, the latter ...

System.Byte[] shows in gridview instead of an image?

大城市里の小女人 提交于 2019-12-07 08:12:43
问题 Hi I have a page that allows me to upload photo. Then when i click upload...the photo has been approved. But when i want to display it in gridview. The column that the image must appear it gives me "System.Byte[]" instead of an image. Help :) Here's my code: <%@ Page Language="C#" Debug="true" %> <%@ Import Namespace="System" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace = "System.Data.SqlClient" %> <%@ Import Namespace= "System.Data.OleDb" %> <script runat="server" type="text

C# Byte[] to BCD and BCD to INT

余生长醉 提交于 2019-12-07 06:21:31
问题 I have a Hex file created by CashRegister Machine. I have to read this file in. File uses formatting detailed below. It is like socket packets. Code Data : 2 Byte PLU Code Data: 7 Byte Unit Price Data: 5 Byte Quantity Data: 5 Byte Total Amount Data: 5 Byte PLU Name Data: 18 Byte Tax Rate Data: 1 Byte Length: 24 + 19 Byte PLU code format is BCD Unit price 1-9999999999 (BCD) quantity 1-9999999999 (BCD last 3 numbers should be decimal) total amount 1-9999999999 (BCD) I read in the hex file with

Uploading files to file server

北城余情 提交于 2019-12-07 05:33:23
Using the link below, I wrote a code for my application. I am not able to get it right though, Please refer the link and help me ot with it... Uploading files to file server using webclient class The following is my code:- protected void Button1_Click(object sender, EventArgs e) { filePath = FileUpload1.FileName; try { WebClient client = new WebClient(); NetworkCredential nc = new NetworkCredential(uName, password); Uri addy = new Uri("\\\\192.168.1.3\\upload\\"); client.Credentials = nc; byte[] arrReturn = client.UploadFile(addy, filePath); Console.WriteLine(arrReturn.ToString()); } catch

Converting a C byte array to a long long

ぃ、小莉子 提交于 2019-12-07 04:46:37
问题 I have an 8-byte array in my application with this data: 00000133339e36a2 This data represents a long (on the platform the data was written in, on a Mac this would be a long long) with the value of 1319420966562 In the actual application this is a semi-randomized set of data, so the number will always be different. Therefore, I need to convert the byte array into a printable long long. I've tried casting the data directly into a long long, but I came up with 1305392 where I should have been