PDA

View Full Version : Solved: Get the value in bytes from string



Movian
04-10-2011, 04:31 PM
Hey,
I have written to the person who i am doing this for however being the proactive person i am thought i would see if i could get ahead and get the info before they read it in a couple days.

I have been asked to create some functions to perform some tasks. One of which is to quote

"Get the value in Bytes from UTF-8 String"

i will then need to hash the byte value... i have been looking around. And im trying to figure out if i need to convert this to a byte array, then append each entry into a string then hash the string... or if they are possibly referring to something else entirely.

While i am asking i will also need to find out how to get a base64string from a string. This i will also be researching but any info web links are appreciated.

I feel a little out of my league dealing with these topics and I'm trying to get my head round them as quick as i can so any help clarification or web links is GREATLY appreciated.

hansup
04-10-2011, 05:28 PM
Find out if those UTF-8 strings can include any of the characters outside the first 128 of the Unicode character set. The first 128 are encoded with one byte each. Beyond that characters require two to four bytes.

So if you're reading single bytes from a UTF-8 string, you can't be certain each byte represents a character.

Movian
04-12-2011, 01:49 PM
What I had meant with the 4th step is that the string created by step 3 is turned into bytes, so that it can be encrypted. So, you get the bytes, then hash that immediately. Then, finally, you output that hashed value as a base64 string. There isn’t an intermediate step of turning the bytes into a string and then encrypting it.


i feel like in getting in over my head, never worked with bytes or base64 values before. Any help interpreting/implementing would be appreciated.

Movian
04-13-2011, 04:57 AM
I finaly found a C# example of what i need

protected static byte[] FromUTF8(string originalString)
{
return utf8.GetBytes(originalString);
}

Aparently it has a built in function to do it from Utf8

would somthing like the following do the job or am i missing somthing ? i = CByte(Asc(Phrase))

Movian
04-18-2011, 10:03 AM
Ok it looks like i am finally starting to make some headway with creating a VBA compatible Encryption library. I have a working library that will allow VBA to create a correct SHA512 hash :)

Will possibly see about expanding it to other hashing types and post it for download.

at any rate, for now am marking this as solved.