|
stephen.darling wrote: As long as I can generate a string of digits that are fixed in length, and different everytime I generate a new serial number, then this method would be fine.
Or, a Guid. Is there any reason that a Guid won't do?
|
|
|
|
|
Hi.
Well in either case, the generated serial would look like the following:
AF54E45D32E... etc
and I want my serial to be formatted like the following:
32443523454234532... etc
But, because my serial would be large, that is why I cant simply use int64 or simular methods.
I have seen code before, and used it years ago that does exactly what I want.
Yes, there are many products that ask for a MD5 style serial, but, if you look at products from ADOBE, AUTODESK etc etc,
they have serial numbers in the following format:
0000-0000-0000-0000-0000
But if I simply created a string and forced it to be numbers, which I have managed to do, when it is encrypted we loose the format and end up with unreadable charicters.
It is easy to find how to then encode these into a readable format, but it is always base32 or base16 and I still want to represent my large serial as digits.
Thank you, I will keep trying to figure this out.
Regards,
Stephen
|
|
|
|
|
stephen.darling wrote: What type of string would this be.
"Anything you like"
There is a description of MD5 here: Wiki[^]
Basically, when you generate a hash, you work out a number based on the content of your input: For example, you could hash a string by adding together all the characters and taking only the last eight bits. If you used this hash algorithm on the same string, your will always get the same hash value. Change a single character in the string, and you will get a different value: It makes it very easy to compare them, and you cannot get back to the string from the hash value: you have discarded information when you took only the last eight bits of the sum.
I'm not suggesting such a simple hash would help you (there are only 256 different values, so it is too easy to find a duplicate), but MD5 always generates a hash value 128 bits (32 hex digits) long. And it is easy to generate:
private void button1_Click(object sender, EventArgs e)
{
string s = "Anything you like!\n" +
"0123456789ABCDEF" +
GetHDDSerialNumber("C");
string MD5 = GetMD5(s);
Console.WriteLine(MD5);
if (CheckMD5(s, MD5))
{
Console.WriteLine("Hash matches: ok");
}
else
{
Console.WriteLine("Hash failed to match: WTF!");
}
string sFail = s + ".";
string MD2Fail = GetMD5(sFail);
Console.WriteLine(MD2Fail);
if (CheckMD5(sFail, MD5))
{
Console.WriteLine("Hash matched: WTF!");
}
else
{
Console.WriteLine("Hash failed to match: ok");
}
}
private static string GetMD5(string input)
{
MD5CryptoServiceProvider MD5Builder = new MD5CryptoServiceProvider();
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(input);
bytes = MD5Builder.ComputeHash(bytes);
System.Text.StringBuilder sb = new System.Text.StringBuilder(bytes.Length * 2);
foreach (byte b in bytes)
{
sb.Append(b.ToString("X2"));
}
return sb.ToString();
}
private static bool CheckMD5(string input, string MD5)
{
return GetMD5(input) == MD5;
}
private static string GetHDDSerialNumber(string drive)
{
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"" + drive + ":\"");
disk.Get();
return disk["VolumeSerialNumber"].ToString();
}
You will need to add a reference to "System.Management" and
using System.Security.Cryptography;<br /> to compile this.
Generate the output (on my machine - it would be different on yours):
DC7A30D78A5D410E5619E60F5514F85C
Hash matches: ok
D0E113EB00B3ECDCEA6CA7AC39D68440
Hash failed to match: ok
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
I have a checkBox in my excel workbook,and I would like to know in my c# application is tht VBA Excel control(chechkBox) set to true or false. How?
Any examples anywhere,or something,so basically how to read data from excel vba in c#
|
|
|
|
|
|
i want to implementing page layout properties of word in C#.net. How can i do this
MURALEEKRISHNAN.K
|
|
|
|
|
1) Assemble a large team - several hundred programmers, managers, project managers, testers, technical authors, etc.
2) Give them a copy of Ami Pro, and tell them "copy that, but don't make it obvious". Allegedly.
3) Go away for ten years or so, remembering to pay them, and hire on more staff when they ask.
4) Done - you now have Word page layout in .NET
Of course, Word has probably moved on a little by then...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Hi All,
In Windows Forms, how can I extend the existing SplitContainer control so that I may add 3, or 4, or more splitContainer Panels using the Design-View Properties Pane?
I have tried to do research on this, but have not found a single thing on the subject.
|
|
|
|
|
hi. i knw how to opn a window like my document on btn clk in c# but i dont knw how to close this window. if i use close() function thn it close the program. how can i clse the windo on btn clk?
modified on Tuesday, March 1, 2011 1:56 AM
|
|
|
|
|
this.Close will close the current Form instance: If this is the main form that was opened when you application started, it will indeed close the application. For other forms it will just close them.
If you need to alter this behaviour, you need to look in "program.cs" at the Main method: the Application.Run(); line starts your form going, and waits until it closes. Be careful to provide some mechanism for closing your application or you will just annoy your users!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Who have you annoyed? I don't know who down voted a reasonable question, but I have compensated.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
It would be some loser who doesn't understand that not everyone in the world speaks English. Imagine the shock when they go OS and discover the world is full of foreigners.
[edit] I take back that comment. It was given a 1 because it was txt [edit]
"You get that on the big jobs."
|
|
|
|
|
OriginalGriff wrote: Who have you annoyed
Everyone who attempts to read the question. I realise english is unlikely to be the OPs first language but that is bloody difficult to read. A bit petty but you asked.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I know what you mean!
Still not a reason for downvoting it though: ignore it instead, or post "wftru n abt?"
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Mycroft Holmes wrote: I realise english is unlikely to be the OPs first language but that is bloody difficult to read.
That's no reason to down vote them. I wonder how many English speakers here could formulate a clear question or answer in Arabic, Hindi, Greek or Russian for example.
I must get a clever new signature for 2011.
|
|
|
|
|
Richard MacCutchan wrote: That's no reason to down vote them
Oh I agree with you there, as I said, very petty.
I once had to communcate with some Japanese devs, bloody impossible, my multi lingual skills are non existent.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If you want to "Close" the Form, then this.Close(); will work. However, if you want to simply hide it, then this.Hide(); will work, and to Dispose of the Window/Form, then use this.Dispose();
|
|
|
|
|
aeman wrote: window like my document on btn clk in c# but i dont klnw how to close this window.
If by this you mean open another program from c# like word the close it
Process []pArry = Process.GetProcesses();
foreach(Process p in pArry)
{
string s = p.ProcessName;
s = s.ToLower();
if (s.CompareTo("winword") ==0)
{
p.Kill();
}
}
Above code will close word application.
|
|
|
|
|
i dont want to opn the another program but i want to close the windo that i opn on the btn clk.
for example if i clk the btn 'MY document' opns now i want to close it not by clking the cross but cliking the btn on my form.
hope question is clear.
|
|
|
|
|
sory i have some mistakes in my question. i have edited my question. i was in hury that day so couldnt notice.
|
|
|
|
|
how send drawing over network connection
and how to make connected member see wat i drawing
in my board
|
|
|
|
|
You have given us very little to work with:
What do you mean by drawing: bitmap type (such as jpg, bmp or gif etc?) or vector type drawing?
What do you mean by send: You could e-mail this which would fulfil your requirements. It looks like you have a requirement to show changes live, how do you want to transfer the picture?
What do you mean by connected member?
What Board?
Just because you have some idea about your system, it does not mean we do!
You have not stated what you have done or what problems you are having (or even just said you have no idea how to proceed), just given a statement of some kind of requirement. Please read the site FAQs /the post at the top of the forum marked "How to Get an Answer to your Question". You are more likely to get a helpful response.
[Edit]
Seriously, read the FAQs and the top post: every single message you have posted has been voted 1 by multiple people.
|
|
|
|
|
imag bitmap or any thing in my board to see other member
in eboard messenger project
|
|
|
|
|
I assume you mean similar to an electronic whiteboard, crossed with a chat application?
If so, then it isn't too difficult: You will need drawing capture / storage / redraw application at both ends, with communications between them.
For the communications, Google for the Sockets class: they provide good solid machine to machine communications. MSDN[^] has a good description and an example.
For drawing, Google for "simple drawing c#" and you will find lots to start you off - remember that you only need to send the drawing elements between PC's (lines, circles, text, etc) - not whole bitmaps!
Good luck!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Try telepathy, or carrier pigeons. Have you considered sacrificing a chicken? Right now, these are about the only ways you are going to have any chance with your project.
|
|
|
|