المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : encoding and decoding in BASE 10



C# Programming
09-15-2010, 03:40 AM
I have searched and searched, and I just cannot find this solution. I know its out there becasuse I found it before.

Ok, I have a byte array of a fixed length, say 5 bytes.

I want to represent the byte array as a fixed length number, without using int, long etc etc.

I then want to be able to have the number entered by the user into an edit box, and encode it back to the byte array.

So, for example...

User enters the following (these are examples, not actual values)

2354 3488 3433 2332

Then this in decoded into its byte array representing the data.

In my seperate generator, I set the bytes, and it encodes as:

2354 3488 3433 2332

I am really looking for 2 brief code sample functions like the following

private void convertSerialNumber(string serial)
{

encode into byte array

}

private void convertByteToSerial (byte[] arr)
{

decode into serial (2354 3488 3433 2332

}

The reason I need to do this, is once I generate the byte array, I want to encrypt it.
If I simply use standard conversion routines, or use the string to int fuctions etc, I cannot do this

Could someone PLEASE provide brief coding examples.

I believe the functions I found before were custom functions using bit operators.

Converting and displaying as hex is no problem as they are built in, and I can find many examples of BASE32 encode/decode, but I relay want to represent my data as digits like 0000 0000 0000 0000

I hope this is clear enough as it is yet again driving me insane, and I am trying, I have spent a few months yet again.

Thank you so much in advance.
Steve