How do i edit raw data from a file in bytes? [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
I want to edit raw data from files (Hex) but i don't know how can i do it
Is there any package that can help me?
Also how do i convert strings in raw bytes?
I've tried some solutions out of google but none of these worked

Here's a function that:
Reads all the bytes from a file
Changes the second byte to the decimal value 8
Writes the bytes back to the file
Note, this is not the most efficient way to do this, but it's an example.
public async Task ChangeSomeBytesInFileAsync(string path)
{
var bytes = await File.ReadAllBytesAsync(path);
bytes[2] = 0b0000_01000;
await File.WriteAllBytesAsync(path, bytes);
}
To get the bytes of a string use the Encoding class and the appropriate encoding In this example, I'm using UTF-8.
var bytes = Encoding.UTF8.GetBytes(#"some value");

Related

GetSerialNumber gives different value than SerialNumber in an X509Certificate2 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have a certificate data (byte array):
var cert = new X509Certificate2(certBytes);
var serialBytes = cert.GetSerialNumber();
var serialString = cert.SerialNumber;
when converting serialBytes to hex format:
BitConverter.ToString(serialBytes).Replace("-","")
it gives a different value than serialString
Because you should read the documentation:
X509Certificate.GetSerialNumber
Returns the serial number of the X.509v3 certificate as an array of bytes in little-endian order.
X509Certificate2.SerialNumber
Gets the serial number of a certificate as a big-endian hexadecimal string.

Convert .wav audio file to text c# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I want to convert .wav audio file to byte and then convert this byte array to string.
I do this using c# but the string it return is not in valid format i.e. not in readable form.
How can i get the string in readable format?
var bytes = File.ReadAllBytes("SomeAudio.wav");
string result = System.Text.Encoding.UTF8.GetString(bytes);
In result the data is not readable i.e. it returns �𣻰��𠀁걄𫄐􀀄�𣻌
You should use System.Text.Encoding.ASCII instead
var bytes = File.ReadAllBytes("SomeAudio.wav");
string result = System.Text.Encoding.ASCII.GetString(bytes)
and for write some sample you can use
FileStream f = new FileStream("a.wav", FileMode.Create);
BinaryWriter wr = new BinaryWriter(f);
wr.Write(System.Text.Encoding.ASCII.GetBytes("RIFF"));
If you want to create blob here is good example "MSSQL" later you can put blob to table in database.
DECLARE #BLOB varbinary(MAX)
SET #BLOB = (SELECT *
FROM OPENROWSET(BULK 'C:\Users\AAAAAAA\Desktop\master\templates\miusic.wav', SINGLE_BLOB) AS BLOB)
SELECT #BLOB

escaping from double quote string [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have string "my string" taken from excel value, I used GemBox.Spreadsheet library. But the result I have """my string""". How to get back my real string value as "my string
Thanks
Use the hex escape \x22 such as:
Console.WriteLine ("\x22Literally\x22");
Outputs "Litterally"
okay I just go to GemBox Convert I try upload my excel file, then convert into csv file, and the result is same as my convert file. So the problem is not coming from my script but in GemBox.Spreadsheet library. Thank you for your participate guys!

XOR encryption - decrypting it [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I want to decrypt a string (HWID) which is being sent to my filter as weird characters.
It was working fine until someone released the bypass for it.
So basically I want to decrypt it and check if it's real or fake.
How I'm getting the string (HWID)?
this.hwid = current.ReadAscii(); //reading the packet
I wanna decrypt it (XOR), this is how the string (HWID) looks like; "y'2&dxw|rrbrne{"df!4* |/qd|'`-r5s "
Ignore the quotes
Any help would be appreciated;
How did I get this idea? A friend of mine who actually made the DLL which sends the string (HWID) gave me a hint. But I don't even know what's XOR. And Please if you don't understand what I mean just comment what u don't understand.
x-or is a boolean mathematical operation. You can learn all about it over here https://en.wikipedia.org/wiki/Exclusive_or
To decrypt using x-or in C# you need to use the XOR operator like this c = a ^ b;
To decrypt your string you need the key (something to x-or it with) and then perform the x-or one character at a time. This will be something like converting the strong to a bytearray and then processing one character at a time.
That would be like this question XOR function for two Hex byte arrays

Windows Phone - Decode ASCII in string [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have ASCII encoding characters in string. Something like this:
%7B%22video%22%3A%7B%22JSONinfo%22%3A%7B%22id%22%3A212096%2C%22title
How can I decode it to "normal" string? I've tried to find an answer but I find solutions for byte[] of ASCII characters and so. I have an idea that I can replace all characters that starts with % by character which they represents but I think there is better aproach. And one more thing, solution must works for windows phone. Thanks
Use HttpUtility.UrlDecode().
For example, for the string you have given, the result is "{"video":{"JSONinfo":{"id":212096,"title"
You have may alternatives. Choose whichever works for WP
string s = "%7B%22video%22%3A%7B%22JSONinfo%22%3A%7B%22id%22%3A212096%2C%22title";
var s1 = System.Web.HttpUtility.UrlDecode(s);
var s2 = System.Net.WebUtility.UrlDecode(s);
var s3 = System.Uri.UnescapeDataString(s);

Categories

Resources