|
Mycroft Holmes wrote: the winner
"Never put off until run time what you can do at compile time."
- David Gries, in "Compiler Construction for Digital Computers", circa 1969.
|
|
|
|
|
Cute? Yep!
Works? Yep!
Easily understood? Nope!
Gets a 5 from me anyway
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."
|
|
|
|
|
Thanks.
"Never put off until run time what you can do at compile time."
- David Gries, in "Compiler Construction for Digital Computers", circa 1969.
|
|
|
|
|
Note, you got 5 for readability, I had no trouble understanding your one but it does not make me indensible
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I knew I was doing something wrong!
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."
|
|
|
|
|
Cute == obfuscated?
One method to divide them, one to combine them again
I are Troll
|
|
|
|
|
Eddy Vluggen wrote: Cute == obfuscated?
You are absolutely right, I'll now spend the next 2 hours trying to work out what JAANs has done.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Eddy Vluggen wrote: One method to divide them, one to combine them again
For some reason that reminded me of this: Ash nazg durbatulûk, ash nazg gimbatul, ash nazg thrakatulûk agh burzum-ishi krimpatul.
|
|
|
|
|
..and somehow, for some obscure reason, that reminded me of marriage
I are Troll
|
|
|
|
|
And, once we take into account your signature, we wind up with the Orc of the Covenant.
|
|
|
|
|
You should have saved that as a Friday Programming Quiz.
This ought to be more efficient than that Linq abomination:
public static string
Repeater
(
string Source
,
char Delimiter1
,
char Delimiter2
)
{
System.Text.StringBuilder result = new System.Text.StringBuilder() ;
int off = 0 ;
while ( ( off = Source.IndexOf ( Delimiter1 , off + 1 ) ) > -1 )
{
for ( int i = 0 ; i <= off ; i++ ) result.Append ( Source [ i ] ) ;
result.Append ( Delimiter2 ) ;
}
return ( result.ToString ( 0 , result.Length - 1 ) ) ;
}
|
|
|
|
|
PIEBALDconsult wrote: Friday Programming Quiz
Not a chance, one of these codz will turn up in my app this morning (with an appropriate link to the author of course).
PIEBALDconsult wrote: return ( result.ToString ( 0 , result.Length - 1 ) )
I didn't realise you could manage the lenght during a tostring() operation.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I didn't realise you could manage the lenght during a tostring() operation.
Lots of people don't; I think I learned it in the last year.
|
|
|
|
|
Is it possible to read data from controls of already loaded form in winforms?
Suppose I have a simple mdi application. I open Form1 from menu. On form1 I fill textboxes with clientID and productID. I keep Form1 open. Now I open Form2 from menu. Can I read clientID and productID of Form1 in load event of Form2?
|
|
|
|
|
If you had a valid reference to the form and the control values were exposed via a property.
Something like this
public class Form1
{
public string ClientID
{
get{ return ClientID.Text; }
set{ ClientID.Text = value; }
}
}
public class Form2
{
public Form2(Form frm)
{
string id = frm.ClientID;
}
}
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Another way to do it would be to have a constructor in your form2 that took two integers as parameters, which can be used to populate two fields in your form2 like this:
int ClientID;
int ProductID;
public Form2(int clientID, int productID)
{
this.ClientID = clientID;
this.ProductID = productID;
}
private void Form1_Load(object sender, EventArgs e)
{
}
Hope this helps.
|
|
|
|
|
hi i have a one question.
I made outlook's add-ins.
Now I want to Make function which If i clicked some button in outlooks's add-in,
Some Contents was saved to someone's outlook schedule.
I hearded, this is possible.
If you know, please let me know about site.
Have a nice Day.
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
buffering83 wrote: I hearded, this is possible.
Yup.
buffering83 wrote: If you know, please let me know about site.
It's called MSDN[^], and has all the samples you need to get started
I are Troll
|
|
|
|
|
Thank You!
I just make program what i want because MSDN which you linked!
Have a nice Day!
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
Thanks for the nice response
I are Troll
|
|
|
|
|
Dear Coders,
I am still frustrated by my problem, so I am going to ask again and hope someone may be able to help me?
First of all, I do not want to use a big num type of library, and I am not looking for the simple built in converters and formatters as this does not help my situation.
I did find code that performed the required encoding and decoding a while ago, but I just cant seem to find it anyware.
I will now explain my problem in as simple a way as I can, and then I will provide additinal info further down to explain exactly what I am trying to do.
OK, here goes...
I want to be able to input a string of any length, normaly it is going to be arround 50 digits...
string input = ("45873476774384759909120192837428394458475988343485")
After the string is entered into a text box, I want to decode the decimal digits into their hex representation and store them into a byte array.
So, if I had the following decimal digits...
67384567845
And converted them into hex, I would end up with:
FB06EE825
And to encode, I want to be able to build a fixed length byte array, for example containing the above hex, and then build a string containing the decimal representation, which for the above would be
67384567845
So, I am looking for an encode and a decode routines to perform the above. I cant simply use the bult in functions as the int, or decimal string will be around 50 digits and I do not want to use big num librarys.
The code I was given ages ago used some kind of binary routines to loop through and "build" the string.
What am I trying to do?
I want to build a byte array of FIXED length to represent the ID and version of my app, with some other data.
I then want to encrypt it
I then want to represent it as decimal digits of a fixed length, and not hex, base 32 etc etc.
I then want to be able to enter the decimal string of 50 digits into an app I built
I then want to decode the string into its hex byte representation of fixed length
I can then decrypt the byte array, and perform matching checks etc
I hope this is clear enough and I will be so gratefull if anyone can help, as binary math is not my area at the moment.
Thank you so so much for any help.
Kind regards,
Steve
|
|
|
|
|
If you're Googling for this using the keywords "encode" and "decode", that's not what you're doing. You're converting a number from one base to another. Google for "convert base 10 to base 16 c#" and you might find something useful.
|
|
|
|
|
Steve, every time you have asked this question, someone has told you: converting a number from base 10 to vbase 16 is not encryption".
Now that you have described what you want to do, can I suggest an alternative, which is used by a lot more software than what you appear to be trying to do:
1) Assemble the string you want to check in your application. This can be any string, as long as your software can generat it.
2) Take the MD5 or SHA hash of the string.
3) Enter the hash value to your application.
4) Your application then generates it's version of the string.
5) It then generates the MD5 or SHA hash of the string it just generated.
6) It then compares the two hashes. If they are the same, it passes.
This way, there is no need to encrypt anything in a way that can be reverse engineered: MD5 and SHA are non-reversible (Well, MD5 is "broken" because there is a way to generate an enter-able string from the hash, but never mind that for now)
The only way to do exactly what you are actually asking for is to convert the string to an number and then convert back into the new base. How much clearer do we have to be?
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,
Thank you for the new idea, could I ask you to clarify step 1 above.
What type of string would this be.
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.
Thank you
Kind regards,
Steve
|
|
|
|
|
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?
|
|
|
|