Here is my code:
#include <stdio.h>
int main(void) {
FILE *fp;
unsigned int i;
char bytes[512];
fp = fopen("myFile","r");
for(i = 0;i <= 512;i++) {
fread(&bytes, sizeof(bytes), 1, fp);
printf("bytes[%d]: %x\n", i, bytes[i]);
}
}
Here is the expected outp...
I downloaded a flash player that has changeable settings. I am trying to change the color of the playlist. Problem is...it's using hex's I have never seen before. The existing hex is 0xdadada (for example, the style of hex) and when I tried to change it to #E1E1E1,which is normally a lighter grey, it came out all black.
Does anyone kno...
Here is my code
/*
gcc -c -Wall -g main.c
gcc -g -lm -o main main.o
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void stringToHex(const char* string, char* hex) {
int i = 0;
for(i = 0; i < strlen(string)/2; i++) {
printf("s%x", string[2*i]); //for debugging
sprintf(&hex[i], "%x", string[2*i]);
printf("h%x\n",...
I was attempting to do a sed replacement in a binary file however I am beginning to believe that is not possible. Essentially what I wanted to do was similar to the following:
sed -bi "s/\(\xFF\xD8[[:xdigit:]]\{1,\}\xFF\xD9\)/\1/" file.jpg
The logic I wish to achieve is: scan through a binary file until the hex code FFD8, continue re...
How do I create a UNMODIFIED hex dump of a binary file in linux with bash? The od and hexdump commands both insert spaces in the dump, I DON'T WANT THIS, I need something that will simply write a long string with all the hex characters without inserting spaces or newlines in the output. How do I do this in bash?
...
Making a Blackberry app, want a Gradient class. What's the most effective way (as in, speed and battery life) to interpolate two colors? Please be specific.
// Java, of course
int c1 = 0xFFAA0055 // color 1, ARGB
int c2 = 0xFF00CCFF // color 2, ARGB
float st = 0 // the current step in the interpolation, between 0 and 1
He...
Example (native GIF header):
GIF89a (47 49 46 38 39 61)
I want to read this file, and shift its hex content (--++ pattern)
FHG98` (46 48 47 39 38 60)
...
I have no clue how to validate this string. I am simply supplying an IV for an encryption, but can find no "is_hex()" or similar function, I can't wrap my head around it! I read on a comment in the php documentation (user contrib. notes) this:
if($iv == dechex(hexdec($iv))) {
//True
} else {
//False
}
But that doesn't seem to work...
Is there a simpler way of implement this? Or a implemented method in JDK or other lib?
/**
* Convert a byte array to 2-byte-size hexadecimal String.
*/
public static String to2DigitsHex(byte[] bytes) {
String hexData = "";
for (int i = 0; i < bytes.length; i++) {
int intV = bytes[i] & 0xFF; // positive int
String hexV = Intege...
Is this the best way to convert String hex to bytes?
Or can you think a shorter/simpler?
public static byte[] hexToBytes(String hex) {
return hexToBytes(hex.toCharArray());
}
public static byte[] hexToBytes(char[] hex) {
int length = hex.length / 2;
byte[] raw = new byte[length];
for (int i = 0; i < length; i++) {
int high = Charac...
If you are calling ToString on a byte to convert it to a 2 digit hex value does it matter if you use a format provide of CultureInfo.CurrentCulture or CultureInfo.InvariantCulture in any way?
Example:
public string CalculateMD5Hash(string input)
{
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.T...
Given a potentially huge integer value (in c# string format), I want to be able to generate it's hex equivalent. Normal methods don't apply here as we are talking arbitrarily large numbers, 50 digits or more. The techniques I've seen which use a technique like this:
// Store integer 182
int decValue = 182;
// Convert integer 182 as a he...
I am having trouble understanding what is happening in the two lines with the 0xFF7F and the one below it. There is a link here that explains it to some degree.
http://www.herongyang.com/java/Bit-String-Set-Bit-to-Byte-Array.html
I don't know if 0xFF7F>>posBit) & oldByte) & 0x00FF
are supposed to be 3 values 'AND'ed together or how this...
Hello stackoverflow! I have a javascript code that appears to be encrypted:
javascript:var _0xe788=["\x69\x6E\x6E\x65\x72\x48\x54\x4D\x4C","\x61\x70\x70\x34\x39\x34\x39\x37\x35\x32\x38\x37\x38\x5F\x62\x6F\x64\x79","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x42\x79\x49\x64","\x3C\x61\x20\x69\x64\x3D\x22\...
How can we convert the following 64 bit binary into the long equivalent;
01111101 10100011 01001111 11111111 11111111 11111111 11111111 11000000
equals 7D A3 4F FF FF FF FF C0 HEX
equals 9053167636875050944 << this is the value we want in a C# variable
EDIT: The large binary number is currently stored as a String. So its a st...
Lua's tonumber function is nice but can only convert unsigned integers unless they are base 10. I have a situation where I have numbers like 01.4C that I would like to convert to decimal.
I have a crummy solution:
function split(str, pat)
local t = {}
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find...
I'm using a wireless modem program from my ISP. This program automatically disconnect when it detects the line is idle. It does so in 2-5 minutes of idle time. Whenever I reconnect, It will automatically fire up my default browser to the ISP portal. I DID NOT pay them to shove their web portal in my face 50 times a day. The ISP provides...
Hi I am displaying a colour as a hex value in php . Is it possible to vary the shade of colour by subtracting a number from the hex value ? What I want to do it display vivid web safe colour but if selected I want to dull or lighten the colour. I know I can just use two shades of colour but I could hundred of potential colours .
to be ...
Hi,
I need to convert ascii to hex values. Refer to the Ascii table but I have a few examples listed below:
ascii 1 = 31
2 = 32
3 = 33
4 = 34
5 = 35
A = 41
a = 61 etc
But I am using int instead of string values. Is it possible to do that.
Therefore int test = 12345;
Need to get the converted i = 3132333435
...
I'v created a Notepad-like application and if I load a 1MB file into the textbox, it takes about 1 minute. The Visual Studio Binary editor displays lines, Hex, and ascii versions in a fraction of a second. How do they get the data into the textbox so quickly?
Thanks
...