|
Thank you for the responce, would your option (c2) do the following, as I found the part of the paper that concerns me, so here it is qouted from the paper itself...
"a 41-digit decimal number. A
decimal number of this length roughly corresponds to a 136-bit binary
number. In fact, the 41-digit number is just the decimal encoding of
such a 136-bit multi-precision integer, which is stored in little
endian byte order as a byte array. Hence, the above Installation ID
can also be represented as a sequence of 17 bytes as in
0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX
0x94 0xAA 0x46 0xD6 0x0F 0xBD 0x2C 0xC8
0x00"
Now, when I looked at the code, there was alot of << operations etc, so that maybe closer.
Also, how do I combine it all together using your option?
If a ushor gives me 5 digits, how do I combine the bytes to form one 20 or 25 digit number?
Thank you again
Steve
|
|
|
|
|
You lost me again. Do you have to implement what is in the text, or are you just looking for a working approach?
Anyway, they may actually have a 136-bit number in there, although I suspect they invented that to explain things more easily (i.e. I think they give a mathematical expose, not a code explanation).
What I proposed is, for 2N bytes, you have N 5-digit numbers; you never hold an overall number. You do have a string containing those N 5-digit numbers and some spaces, if that is the format you choose. It takes some string operations to aggregate that (and later split it again).
|
|
|
|
|
I was just looking for a working approach, although, there is code in c++ that decodes a string of 41 digits like the following "34234234459890798734987298374 etc" into that byte array. When I use my graphic calculator, the long string of digits does end up being the byte array, it just seems so hard to implement.
It is stange, if I have a byte array, I can very quickly output it as a string, represented as a hex or base32 etc. But representing a byte array as numbers seems so difficult.
Thank you for your help anyway, I do appreceate it alot.
I think for now Ill have to generate the serial number by hand and leave it unencrypted.
Thank you again,
Steve
|
|
|
|
|
stephen.darling wrote: But representing a byte array as numbers seems so difficult.
Do you want to assume the byte array is a binary representation of a large number, then convert that number to it's base10 form in a string? For example:
byte[] bigNumber = {1, 22};
Would be converted to:
string strBigNumber = "278";
You can use the BigInteger data type in .Net Framework 4 to help with that. There are also articles on how to do this if you are using an earlier version of the .Net Framework.
|
|
|
|
|
Aw bignumber? Ill have a look into that. thank you
Steve
|
|
|
|
|
Hi,
I don't know if I may help, but if I understand it well
your problem goes like this:
1. you have a fixed sequence of bytes, say you have
an array of 16 bytes. This may represents a number (more
precisily an unsigned or signed integer) in extended precision
in binary format (i.e. in base 2).
2. you want to handle this number and to convert it in
decimal base (base 10). Hence you get a nice base 10
representation outputted as a formatted string.
3. you want to be able to go back from the decimal
representation to the binary (base 2) one.
Trivial Example: do suppose your array is just 4 bytes long
(i.e. the standard size of an int)
namely you have in hex the value 0x0abc
stored as a four byte array in binary (base2) as:
(leading zeroes omitted) ...0000101010111100
you then want to convert it to the decimal representation
(base 10) with result: the string "2748".
and then be able to convert it back to its binary format
in base 2 in order to access it byte wise.
Well if this is right I think then you shall use
multiple precision arithmetique techniques: i.e.
you define a size (say 128 bytes) for your extended
precision integer and then you want a couple of functions
encodeBase10, decodeBase10 in order to be able to represent
such a number as a decimal string and convert back from it.
If such is your intention, you may take a look at the
GNU library "gmp", i.e. a multi precision library.
-----------
Instead of the solution above, you may want to do a translation byte
by byte, then the other method proposed in this thread
is just to output a converted value for each byte
in decimal taking care to pad with leading zeros where
needed, i.e. you transform from this:
(base 2) 00011010 00001111 00000111 10000011 - four bytes
to this
(base 10) 026 015 007 131 - string with 12 digits
and then convert back by grouping the string digits
3 by 3.
or if using ushort's instead of bytes,
you play with groups of 5 decimal digits
(always padding leading zeroes).
In this second case, for example, you have that a 25 long
string base10 digit represents 6 unsigned short numbers
and hence 12 bytes.
Hope this points you to the desired solution,
Cheers
|
|
|
|
|
Don't you mean an uint at C3?
|
|
|
|
|
I sure do. Thanks.
|
|
|
|
|
Is it possible to write a code that adds today's date to a jpg photo?(the date is changed everyday)
|
|
|
|
|
To what? The filename? The image itself? Data inside the image (aka steganography)?
|
|
|
|
|
if you want to create a new image file containing the original image plus a legend or a watermark, this pseudo-code should do:
Bitmap bm=Bitmap.FromFile(filepath);
Graphics g=Graphics.FromImage(bm);
g.DrawString(...);
bm.Save(someOtherFilepath, ImageFormat.Jpeg);
bm.Dispose();
FYI: this simple scheme will fail when someOtherFilepath==filepath
|
|
|
|
|
Visible or not visible? If you want it visible then what you should be searching for is jpg watermark c# (which gives you an article here as the first google result). If you want it invisible then what you want is called steganography for which there is a whole series of articles here as well.
|
|
|
|
|
The quantity resulting from the summation of today's date and a JPG photo will result in two terms that connot be simplified. You can, however, store the result symbolically rather than numerically.
|
|
|
|
|
huh? what do you mean by that? can you send the codez plz. It's kind of urgent ya know.
|
|
|
|
|
I have a list of phone numbers, some of them are valid and some of them aren't. I have to write a simple program, which will check which phone number is valid and which isn't.
I thought to use SerialPort for this, but how can I disconnect directly after the first beep (before somebody answers the phone) or after I got message from the carrier that the phone number isn't valid?
Or may be there is some other way to solve it?
Thanks in advance
|
|
|
|
|
|
Hi fellas,
I wanna know what is the best pattern to my web application to use LINQ to SQL in project.
|
|
|
|
|
|
Is that a design pattern now? And I've been using it for ages!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
You are going at things completely backwards. First you figure out what problem you are trying to solve. Then you decide what patterns provide the best solution for that problem. Then you decide what tools to use to implement those patterns.
The way you are doing things is like asking "What is the best vehicle to buy if I want it to be blue?" It may work out fine, but you may end up trying to drive a blue boat through desert sand or a blue motorcycle across the ocean floor.
|
|
|
|
|
The Avoid-Like-The-Plague pattern.
|
|
|
|
|
Dear Coders.
My app requires the display of simple animations using a picture box or custom control.
Now, could I create an animated GIF and load this into the control, or should I create each individual bitmat and load them one after the other, re-creating the animation?
I do not want to create a 'video' and load that, I need full control over the animation(s).
Thank you
Steve
|
|
|
|
|
An easy way is to override on paint and then use double buffering to paint your animations. The best way is to get a background image and then draw sprites on top of the image rather than trying to let GDI+ render an entire frame. It is painfully slow.
|
|
|
|
|
you could do it either way. Animated GIF has the advantage of being simple, once you have the one file.
CodeProject holds an article (with NGIF in the title) that shows one way to turn a series of images into an animated GIF.
|
|
|
|
|
Thank you, I will have a look!
Steve
|
|
|
|