|
string txt1 = "some_text";
string txt2 = "anything_else";
ASCIIEncoding enc = new ASCIIEncoding();
ASCIIEncoding enc2 = new ASCIIEncoding();
byte[] kb1 = enc.GetBytes(txt1);
byte[] kb2 = enc2.GetBytes(txt2);
MessageBox.Show(kb1 ^ kb2);
Operator '^' cannot be applied to operands of type 'byte[]' and 'byte[]'
damm, what I did wrong?
=====================
http://wasp.elcat.kg
|
|
|
|
|
You need to ^ each byte, not the whole lot. You need to step through the strings, and can only perform the operation on the set of bytes that exists in both arrays, so unless the two strings are always the same length ( which they are not in your example ), I doubt you're going to get what you wanted.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Ok, is there any other simple way to encode\decode some string?
=====================
http://wasp.elcat.kg
|
|
|
|
|
Yes, there is apparently heaps of encryption/decryption stuff in .NET, but I confess to not having used any of it, yet.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
You will have to iterate the array and do the operations individually on every byte.
<br />
for(int i=0; i<10; i++)<br />
kb1[i] ^= kb2[i]; <br />
Cheers
Kannan
|
|
|
|
|
Besides the above suggestion, you can after this, create a BitArray with the byte[] and use its Xor method.
I see dumb people
|
|
|
|
|
I am currently developing a waveform graph control, and I am having difficulty in dynamically displaying multiple plots. Basically, I want to display anywhere from one to an undetermined number of plots on a single graph; I could use arrays to do this, but there would be difficulty resizing the arrays if I set the size of the arrays too low, and there would be wasted resources if I set the size of the array to high... What I need is an efficient way to add, update, and remove structures representing plot data that can be easily and efficiently resized -- is there a straightforward way to do this in C#??
Matthew Alan Gray, B.S.C.E.
Graduate Student, Mississippi State University
mag2@ece.msstate.edu
|
|
|
|
|
And another one...
COM rules state that to check if two interfaces point to the same COM object, QI both interfaces for IUnknown directly, and compare the results.
How do I do that in C#?
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
Equals() method takes care of that for you or == operator.
The mistakes made in this API make me realise that Microsoft has become big enough that it can shelter morons. If anyone working for me wrote anything this bad and tried to release it, I would kill them and display the body as a warning to the rest of the team. - Christian Graus about C# - GDI+
|
|
|
|
|
Hi,
Is ArrayList a "reasonable" replacement for both vector and list?
It feels a bit weird, but the best I could find in the System.Collecitons namespace.
TIA
Peter
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
|
Just watch out, as by default it does a shallow copy. And of course you have to cast it back to the type you're looking for
Regards
Barry
|
|
|
|
|
HI!
Is there an free FTP class library for .NET available?
OR an open source project that write a FTP class?
gicio
|
|
|
|
|
|
This is a first !!!!
After working on my final project for school late last night, I woke to find the debugger gremlins had come.
When I try to debug my project (F5) MS VC# hangs. The task manager show a process for my app was created, but the app never shows up as a task. I tried deleting the debug directory and doing a rebuild, no luck! If I execute without the debugger (ctrl+F5), either in release or debug build, the app runs.
Sounds like a real world release nightmare
If anyone has ideas, please please let me know.
Thanks,
Paul
|
|
|
|
|
|
Thanks leppie!
Needed to reboot too, but all is well.
Paul
|
|
|
|
|
|
i am using code Access security police tool (caspol.exe).
when i execute this command
caspol -machine -addfulltrust WinService1.exe
then the following message display on command prompt.
-----------------------------------------------------------------
Microsoft (R) .NET Framework CasPol 1.0.3705.0
Copyright (C) Microsoft Corporation 1998-2001. All rights reserved.
ERROR: This assembly is not strong name signed
Usage: caspol <args> ...
caspol -af
caspol -addfulltrust <assembly_name>
Add full trust assembly to policy level
------------------------------------------------------------------
i know that strong name tool(sn.exe).
but i could not understand which options and arguments i have to use
in order to remove the following error
-----------------------------------------------
ERROR: This assembly is not strong name signed
-----------------------------------------------
can any body tell the command with correct option and arguments ?
i will be very thank full to to you.
r00d0034@yahoo.com
|
|
|
|
|
First get to the same directory your source code is located in then use the sn tool like so sn -k mykey.snk
Now find the AssemblyInfo.cs or .h/.cpp file and find where it says
In C#:
[assembly:KeyFile("")]
In C++:
[assembly:KeyFileAttribute("")]
Change the values of each to point to the mykey.snk file.
In C#:
[assembly:KeyFile(@"..\..\mykey.snk")]
In C++:
[assembly:KeyFileAttribute("mykey.snk")]
Now you should have a strongly named assembly. The down side is that you need to do this to all assemblies your code references (excluding the ones that come with .NET).
Good Luck,
James
"The elastic retreat rings the close of play as the last wave uncovers
the newfangled way.
But your new shoes are worn at the heels and
your suntan does rapidly peel and
your wise men don't know how it feels to be thick as a brick."
"Thick as a Brick" from Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
its not working for vc++.net and managed code
my code is not working after using these lines
although c# code is working but the problem is with vc++.net managed code.
----------------------------------------
sn -k mykey.snk
[assembly:KeyFileAttribute("mykey.snk")]
-----------------------------------------
is there any other step to perform pls tell ?
r00d0034@yahoo.com
|
|
|
|
|
imran_rafique wrote:
its not working for vc++.net and managed code
By not working do you mean it isn't compiling?
I assume that is the case because I forgot that the actual attribute name is
[assembly:AssemblyKeyFileAttribute("mykey.snk")];
I forgot the Assembly portion of the name
James
"The elastic retreat rings the close of play as the last wave uncovers
the newfangled way.
But your new shoes are worn at the heels and
your suntan does rapidly peel and
your wise men don't know how it feels to be thick as a brick."
"Thick as a Brick" from Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
Friends,
I am trying to save the image in a picturebox to a file.
It returns a gdi+ error
This is what I do :
tmpfileloc= apppath + "temp_make.jpg";
FileStream fs= new
FileStream(tmpfileloc,FileMode.OpenOrCreate,FileAccess.Write);
Image tmpimg= pictureBox1.Image;
tmpimg.Save(fs,ImageFormat.Jpeg);
fs.Close();
And the error I am getting is this :
An unhandled exception of type
'System.Runtime.InteropServices.ExternalException' occurred in
system.drawing.dll
Additional information: A generic error occurred in GDI+.
Whats wrong ?
Tweety
If you can smile when things go wrong, you have someone in mind to blame
|
|
|
|
|
|
Hi Leppie,
Thanks for the prompt reply.
I am loading the image into the picturebox from a JPG file in my desktop. And the program does create a 0 byte file, when I try to save it. Then it crashes.
Specifying the fileaccess as FileAccess.ReadWrite doesn't stop the error. What is 24bppRGB format ?
Tweety
If you can smile when things go wrong, you have someone in mind to blame
|
|
|
|