|
I want to encrypt/decrypt some data with RSA. I have the private key (D and Modulus) and the public key (Exponent and Modulus) saved in text files.
When I tried to decrypt (encrypt data with private key) I tried to import RsaParameters with D and Modulus set to the values in the file and the other parameters set to null. On the Import method it throws a "Bad Data" Exception. It seems that I can only import RsaParameters when all of the parameters are set? Can I do it any other way?
|
|
|
|
|
Bad Data exception can occurs when your key is wrong. Your private key and modulus are binary data, perhaps they have been ASCII armoured in the text file?
|
|
|
|
|
I think that the error you are getting might be related to the length of the data you are trying to encrypt.
RSA was designed for encrypting/decrypting cryptographic keys, not data. I cannot remember off the top of my head the max length, but if you plough through the MSDN Documentation, it is in there somewhere.
As I said at the start this is only a MIGHT BE, but given that RSA has this length problem you would be better off switching to another encryption provider now, rather than wait till it breaks before doing so.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
No, the exception is thrown on the Import()-method, while importing the keys. I checked the keys also, they're all correct...
In fact this gives the error:
<br />
RSACryptoServiceProvider provider1 = new RSACryptoServiceProvider();<br />
RSAParameters p1 = provider1.ExportParameters(true);<br />
<br />
RSAParameters p2 = new RSAParameters();<br />
p2.D = p1.D;<br />
p2.Modulus = p1.Modulus;<br />
<br />
RSACryptoServiceProvider provider2 = new RSACryptoServiceProvider();<br />
provider2.ImportParameters(p2);<br />
|
|
|
|
|
The only thing that strikes me as, possibly, odd about your code is the creation of p2 . Why not simply re-use p1 ?
RSACryptoServiceProvider provider1 = new RSACryptoServiceProvider();
RSAParameters p1 = provider1.ExportParameters(true);
RSACryptoServiceProvider provider2 = new RSACryptoServiceProvider();
provider2.ImportParameters(p1);
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Because all the parameters of p1 are set, and i want to simulate a situation where there are only the D and Modulus parameters set...
|
|
|
|
|
Ok.
I am afraid that I have now officially run out of talent on this topic. Sorry, but good luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
"Provider=Microsoft.Jet.OLEDB.4.0;"
+ "Data Source=\"" + dir + "\\\";"
+ "Extended Properties=\"text;HDR=No;FMT=Delimited\"";
I'm using the above connection, together with a SELECT * FROM file statement, to pull in data from a comma-delimited text file, where dir is the directory where the file is located and file is the name of the csv file.
This works well for files that contain English characters only, but for any file that uses non-English (ASCII) characters, the expression fails.
I have written the csv file using a StreamWriter with Encoding=UTF8 so the characters display fine when viewed in Notepad or Excel, but when pulled into the DataTable, the value in the table is blank. Is there some Extended Property that can be used to permit East Asian characters, say, to be displayed properly? Thanks.
|
|
|
|
|
Does this[^] helps?
जय हिंद
|
|
|
|
|
Hi All,
While downloading files from FTP server using WEBClient class, I'm able to download first file (while looping through all the files)to my local system after that i'm getting the error "The remote server returned an error: (530) Not logged in".
The credentials are correct as the first file is getting downloaded successfully
Following is the code
FileInfo fi = new FileInfo(strFileName);
if (!fi.Extension.ToLower().Equals(".csv")) return false;
if (serverUri.Scheme != Uri.UriSchemeFtp)
{
return false;
}
// Get the object used to communicate with the server.
using (WebClient request = new WebClient())
{
//request.Proxy = null;
//request.BaseAddress = serverUri.ToString();
// This example assumes the FTP site uses anonymous logon.
string strUsername, strPassword;
strUsername = this.FtpUserName;
strPassword = this.FtpPassword;
request.Credentials = new NetworkCredential(strUsername, strPassword);
string strListeningDir = "";
strListeningDir = this.ListeningDirectory;
strFileName = this.FileName;
try
{
Logger.Write(serverUri.ToString());
newFileData = request.DownloadData(serverUri.ToString().Trim());
fileString = System.Text.Encoding.UTF8.GetString(newFileData);
FileStream fs = new FileStream(strListeningDir + strFileName, FileMode.Create);
fs.Write(newFileData, 0, newFileData.Length);
Logger.Write("File copied to listening directory...");
fs.Close();
GC.Collect();
}
catch (WebException e)
{
throw e;
}
}
return true;
|
|
|
|
|
1. Use the pre tags for your code.
2. What line do you get the exception on?
|
|
|
|
|
hi everyone
I would like to know how to code a server to create an application in C # client / server.
The database used is SQL server, it contains 7 tables.
And more specifically how I can code a server in c # so that multiple users can simultaneously access and complete their treatment (addition, modification, deletion, printing, consulting, research)
I hope to have an answer because it will determine my future work.
Thank you in advance
|
|
|
|
|
tech.csharp wrote: multiple users can simultaneously access and complete their treatment
Concurrency can be handled at the database level and google can provide a lot of help on it.
tech.csharp wrote: addition, modification, deletion
There is a huge namespace SQLClient dedicated for this purpose. Use the classes it has to offer.
Here[^] is an article that can help you.
जय हिंद
|
|
|
|
|
I half expect a reply consisting of; "Thanks, but where r the codez."
|
|
|
|
|
Thank you for your help, and I would like to know how I can insert my access code to database sql, for example customer identification (login and password in the fields of the table)
Thank you once again
|
|
|
|
|
Check out the SqlCommand class, and create a SQL connection using System.Data.SqlClient.SqlConnection class, don't forget to check out this link[^] for information on how to construct a connection string.
|
|
|
|
|
Thank you for your help but I know how create a sql connection string but what I don't know is to manage the connection to a sql server database in a client/server application and any necessary treatment.
|
|
|
|
|
Hi
I am getting this error while creating the setup file.....
The following files may have dependencies that cannot be determined automatically. Please Confirm that all Dependencies have been added to the project.
C:\windows\mscomm32.ocx
how solve it... Please give me Solution
THanks in advance
|
|
|
|
|
your project depend on mscomm32.ocx
and may be you have been taken this project copy and paste so you must add this tool(mscomm32.ocx) again
|
|
|
|
|
Hi Sir
I added it but the Result is Same...
is there any other way to solve...
|
|
|
|
|
Use the SerialPort control instead of mscomm32.ocx.
|
|
|
|
|
basically I want to clear the selection and keep a context menu from coming up if the user right clicks in empty space beneath the last row. The MouseDown event fires before the CellMouseDown event so I can't have the latter set a flag to control the former. The former gives a mouse coordinate but I don't see a way to check if it's on a row or not.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
As to this comment:
dan neely wrote: I don't see a way to check if it's on a row or not
there's the HitTest[^] method. You may find the example code in the docs useful.
|
|
|
|
|
Thanks. The only problem with kitchen sink classes is that intelligence isn't that helpful when it returns 10 zillion items.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Hi all,
I am quite new to C# and I bumped into this issue and I cannot understand why it is happening. I have a list of objects of class1. class1 has, as a member variable a list of objects of class2, and class2 has as a member variable a list of objiects of class3. In my code I have to add some objects to the list of objects of class3 for the last element of the list of objects of class2 for one of the elements of the list of objects of class1. It seems it should be straight forward but i found a strange behaviour and maybe you clever people can help me make some sense out of it.
I'll explain with an example: if the list of objects of class1 has 2 elements (ListClass1[0] and ListClass2[1]) and I do
ListClass1[0].ListClass2[ListClass1[0].ListClass2.Length-1].ListClass3.Add(ObjClass3)
at the end of this I find that the ObjClass3 has been added to ListClass1[1].ListClass2[ListClass1[1].ListClass2.Length-1].ListClass3
Why is that happening?
Is there any way around this?
Cheers
Mauri
|
|
|
|