|
yeh i see what your saying, basically the way i am controlling this is like this, the user will choose the file to be decrypted which will be on the on the CD, once they choose that file i want to move it to somewhere i specify on the C: drive then i will have the user click my decrypt button(where a new form is launched to input a password i supply(I'm using the password for both the iv and key) and it will decrypt and unzip the data and automatically launch a web browser in a form that is going to be linked to the index.html in the unzip folder.
after the new form or my program is closed i want to erase everything i created on the C: drive, i realize that security isn't perfect here but the fact is the end user can have the unencrypted data, but i understand what your saying packaging the decryption tool with the data is risky but without my password to decrypt the file its worthless. im using Aes 256 so its going to take some time to decrypt my password if some one really wanted it. hope i answered your question?
if not ill try again just ask away, thanks for the comment
|
|
|
|
|
Everything you need is in System.IO , for example the File class has Copy and Delete methods. Basic code would look like this:
string sourcePath = ".....";
string destinationPath = "......";
File.Copy(sourcePath, destinationPath);
File.Delete(destinationPath);
If I understand your post, there is still a problem with packaging up the decryption utility.
a) If your password is not the key then the encryption is only as good as the password strength (and the code to verify the password). It is also open to automated attempts at finding the password.
b) If you use both the key and the iv as the password, you need will need to send these as plain text to the user.
c) Along side b, Long keys are unlikely to be entered correctly by the user, short values are are susceptible to brute-force attacks).
d) You will need to obstifucate your decrypter to. PosssiblyAntoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
yes i have tried the File.Copy and the File.Move. i know the way i did them is right because if i run my program with the file on the C: drive and not a CD then it works. but when i try to get the file to copy or move from CD which happens to be my E: drive i get the error.
decryption failed Access to the path E:\bb.zip.dpa is denied.
if i have my encrypted file anywhere but on my CD then my program works fine. below is my code for when i open the file with a file browser dialog and here i try to copy the file. also i point out where it breaks and throws the Access is denied error
private void btnOpen_Click(object sender, EventArgs e)
{
ofdMain.Title = "Select file to Decrypt";
ofdMain.Filter = "Crypt files (*.dpa)|*.dpa";
if (ofdMain.ShowDialog() == DialogResult.OK)
{
txtBoxDecrypt.Text = ofdMain.FileName;
OutputFileNameDe();
string path = txtBoxDecrypt.Text;
string path2 = @"c:\temp2\MyTest.txt";
try
{
if (!File.Exists(path))
{
using (FileStream fs = File.Create(path)) {}
}
if (File.Exists(path2))
File.Delete(path2);
File.Move(path, path2);
Console.WriteLine("{0} was moved to {1}.", path, path2);
if (File.Exists(path))
{
Console.WriteLine("The original file still exists, which is unexpected.");
}
else
{
Console.WriteLine("The original file no longer exists, which is expected.");
}
}
catch (Exception ex)
{
Console.WriteLine("The process failed: {0}", ex.ToString());
}
}
}
thanks again for all your help, if i need to provide anything else let me know.
|
|
|
|
|
Aha! File.Move won't work as the CD is read-only and Move attempts to delete after copy. You should do a straight copy, then delete the temporary file when the decryption is done.
I'd also strongly suggest renaming your file paths something *like* SourcePath , TempFilePath and DecryptedFilePath as this saves a lot of potential pain if these get confused!
Another thing that occurs to me is, if memory serves, decryption happens in a stream, writing this out directly to the file via a FileStream would probably be more efficient than copy /decrypt/delete.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
i just ran my app from a flash drive it worked perfect why am i getting access denied when i run my application and file from a CD???
|
|
|
|
|
A move would imply a "copy & delete" operation, and that would fail on a CD. Try again after you replace the File.Move with a File.Copy as keefb suggested I are Troll
|
|
|
|
|
here is my code i used to copy the file, i get the same error any idea why ??
private void MoveFile()
{
System.IO.File.Copy(sourceFile, destFile, true);
if (System.IO.Directory.Exists(sourcePath))
{
string[] files = System.IO.Directory.GetFiles(sourcePath);
foreach (string s in files)
{
fileName = System.IO.Path.GetFileName(s);
destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(s, destFile, true);
}
}
else
{
Console.WriteLine("Source path does not exist!");
}
}
|
|
|
|
|
Where does this break, and what is the message?
In the code:
shadowthief_03 wrote: foreach (string s in files)
{
// Use static Path methods to extract only the file name from the path.
fileName = System.IO.Path.GetFileName(s);
destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(s, destFile, true);
}
Don't re-use the variables fileName or destFile , declare with different names, or you'll get the world of pain later.
There is a danger (in fact I *think* it is certain) that the loop above will re-copy the file copied in the first line inside the method you posted. You will get an access denied message if that file is marked as read only on the file system (i.e. recopying onto a readnly file already copied). You could try removing that line from the code.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
wait i got it figured out you where right about the copy, and i wasn't using file.copy the right way thanks to everyone for your help i really appreciate it
|
|
|
|
|
shadowthief_03 wrote: here is my code i used to copy the file, i get the same error any idea why ??
It might be because there's already a file on your system. You're mentioning that you want to overwrite this file if it exists, in the File.Copy statement;
System.IO.File.Copy(s, destFile, true); This will fail with a "UnauthorizedAccessException" if there's a pre-existing file that's read-only. A file that has been copied from CD will have the read-only flag set, preventing it from being overwritten by a File.Copy .I are Troll
|
|
|
|
|
hi
How to Load & Save to val's in app.config file ?
for example: to save & to load Connection string
thank's in advance
|
|
|
|
|
1) to add in the xml:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="MyConfig" value="MyValue" />
</appSettings>
</configuration>
2) to load/read something like this:
string myConfig =
System.Configuration.ConfigurationSettings.AppSettings["MyConfig"];
|
|
|
|
|
Hello all,
I am trying to create a UserControl that has some Style properties, I am not sure how to get the Style or StyleCollection to show up correctly in the Designer. I can set
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
and it will display all the Style types without a group i.e. Style-BackColor, Style-BorderColor etc. But when I set
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
the Style property does not show up at all. If anyone knows of a good article on this that would be a great help also.
Thanks!
-Andy
|
|
|
|
|
i want code for a program:
i want to enter a number in between 4000 and 8000.also that entered number must contain a digit 2.otherwise it show invalid. eg:4002,4012,5222.
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:47am.
|
|
|
|
|
thanks for your kind reply.
I am a fresher in this field..
Can u please give me a detailed explanation?
Then it will be very helpful to me...
|
|
|
|
|
And I want money
Anyway here's one way to do it:
1)Check if number is between 4000 and 8000
2) If so then check if it contains a "2". Something like this:
string nr = yourNumbert.ToString();
if(nr.Contains("2")){//do stuff
else{//complain about it
|
|
|
|
|
thanks for your kind reply.
I am a fresher in this field..
Can u please give me a detailed explanation?
Then it will be very helpful to me.....
|
|
|
|
|
thanks for your kind reply.
I am a fresher in this field..
Can u please give me a detailed explanation?
Then it will be very helpful to me...
|
|
|
|
|
thanks for your kind reply.
I am a fresher in this field..
Can u please give me a detailed explanation?
Then it will be very helpful to me....
|
|
|
|
|
It's getting Exam Time Again... Bram van Kampen
|
|
|
|
|
Unfortunately, I'll have to work hard and save up.
|
|
|
|
|
Good Morning,
When my application opens, it checks a version number from an online database to determine if it is using the most current version available. If not, I need it to be able to download the most current version from an online server and then install the application update automatically. I know we see examples of this every day, such as security updates in Windows or online checks for anti-virus programs. The check and automatically close if not installed are already working fine and return a Boolean. How do I force and install the download?
Thank You, Pat
|
|
|
|
|
|
Thank for your answer. I have marked it as correct for this issue. I was able to use it to get the string of code that I needed to resolve the download problem. Now, I need to be able to find a way to automatically install the download. Best Regards, Pat
|
|
|
|