Click here to Skip to main content
15,914,416 members
Home / Discussions / C#
   

C#

 
AnswerRe: windows service username Pin
Ennis Ray Lynch, Jr.17-Sep-10 3:45
Ennis Ray Lynch, Jr.17-Sep-10 3:45 
AnswerRe: windows service username Pin
Mycroft Holmes17-Sep-10 4:58
professionalMycroft Holmes17-Sep-10 4:58 
QuestionOK, how would I do this in c# please Pin
stephen.darling16-Sep-10 12:34
stephen.darling16-Sep-10 12:34 
AnswerRe: OK, how would I do this in c# please Pin
harold aptroot16-Sep-10 12:40
harold aptroot16-Sep-10 12:40 
GeneralRe: OK, how would I do this in c# please Pin
stephen.darling16-Sep-10 12:46
stephen.darling16-Sep-10 12:46 
AnswerRe: OK, how would I do this in c# please [modified] Pin
Luc Pattyn16-Sep-10 13:24
sitebuilderLuc Pattyn16-Sep-10 13:24 
GeneralRe: OK, how would I do this in c# please Pin
stephen.darling16-Sep-10 13:47
stephen.darling16-Sep-10 13:47 
GeneralRe: OK, how would I do this in c# please Pin
Luc Pattyn16-Sep-10 13:58
sitebuilderLuc Pattyn16-Sep-10 13:58 
GeneralRe: OK, how would I do this in c# please Pin
stephen.darling16-Sep-10 14:13
stephen.darling16-Sep-10 14:13 
GeneralRe: OK, how would I do this in c# please Pin
Luc Pattyn16-Sep-10 14:19
sitebuilderLuc Pattyn16-Sep-10 14:19 
GeneralRe: OK, how would I do this in c# please Pin
stephen.darling16-Sep-10 14:31
stephen.darling16-Sep-10 14:31 
GeneralRe: OK, how would I do this in c# please Pin
Luc Pattyn16-Sep-10 14:51
sitebuilderLuc Pattyn16-Sep-10 14:51 
GeneralRe: OK, how would I do this in c# please Pin
AspDotNetDev16-Sep-10 15:46
protectorAspDotNetDev16-Sep-10 15:46 
AnswerRe: OK, how would I do this in c# please Pin
PIEBALDconsult16-Sep-10 16:15
mvePIEBALDconsult16-Sep-10 16:15 
GeneralRe: OK, how would I do this in c# please Pin
stephen.darling16-Sep-10 16:50
stephen.darling16-Sep-10 16:50 
AnswerRe: OK, how would I do this in c# please Pin
David Skelly16-Sep-10 22:22
David Skelly16-Sep-10 22:22 
GeneralRe: OK, how would I do this in c# please Pin
AspDotNetDev17-Sep-10 10:14
protectorAspDotNetDev17-Sep-10 10:14 
Questionjust cant get this code to produce correct value Pin
stephen.darling16-Sep-10 10:08
stephen.darling16-Sep-10 10:08 
Hi again everyone.

I figured out how to represent a string of digits as its byte encoding representation, by converting c++ code that does just this, but it is producing the wrong result and I dont know why...

Here is the working code from my app...

private void button1_Click(object sender, EventArgs e)
        {

            string serialNumber = ("123456789");
            byte[] output = new byte[5];

            int result = decodeSerial(serialNumber, output, 5);




        }


        static int decodeSerial(string serial, byte[] result, int ResLen)
    {

        int   m;
        int  digit, aux;


        Array.Clear(result, 0, ResLen);

            for (int i = 0; i < serial.Length ; i ++)
            {
                
                digit = serial[i] - '0';

                    aux = digit;
                    m = 0;

                    do
                    {
                        aux += result[m] * 10;
                        result[m++] = (byte)(aux % 255);
                        aux >>= 8;
                    }
                    while (m < ResLen);

                    digit *= 2;
                   
            }

         return 0;
    }


    }


Now, when I pass in the string "123456789" I should get the byte encoding of:

0x75, 0xBC, 0xD1, 0x05 (Workis on my calculator AND it worked in a c++ app with the ORIGINAL c++ code,

But in this app, it produces the following hex data...

45, 9A, 71, 07


I def want to use this function, as when it works, I will be passing in a string of digits 41 in length, and besides, the original c++ function worked many months before when I tried it, but now I am using c#.

I would also prefer not to use bignum or any other type of function.

Can anyone help out please?
Thank you

Steve
AnswerRe: just cant get this code to produce correct value Pin
Luc Pattyn16-Sep-10 10:24
sitebuilderLuc Pattyn16-Sep-10 10:24 
GeneralRe: just cant get this code to produce correct value Pin
stephen.darling16-Sep-10 10:43
stephen.darling16-Sep-10 10:43 
GeneralRe: just cant get this code to produce correct value Pin
Luc Pattyn16-Sep-10 10:50
sitebuilderLuc Pattyn16-Sep-10 10:50 
AnswerRe: just cant get this code to produce correct value Pin
T M Gray16-Sep-10 10:40
T M Gray16-Sep-10 10:40 
GeneralRe: just cant get this code to produce correct value Pin
stephen.darling16-Sep-10 10:58
stephen.darling16-Sep-10 10:58 
GeneralRe: just cant get this code to produce correct value Pin
Richard MacCutchan16-Sep-10 22:44
mveRichard MacCutchan16-Sep-10 22:44 
GeneralRe: just cant get this code to produce correct value Pin
T M Gray17-Sep-10 4:08
T M Gray17-Sep-10 4:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.