이 코드는 온라인에 있습니다.이 프로그램에서 무엇이 전달되는지 알고 싶습니다.이 출력과 입력 문자열은 무엇입니까? 입력을 파일 이름으로 전달하고 경로로 출력하지만 오류가 발생합니다.파일 암호화 C#
private void EncryptFile(string inputFile, string outputFile)
{
try
{
string password = @"myKey123"; // Your Key Here
UnicodeEncoding UE = new UnicodeEncoding();
byte[] key = UE.GetBytes(password);
string cryptFile = outputFile;
FileStream fsCrypt = new FileStream(cryptFile, FileMode.Create);
RijndaelManaged RMCrypto = new RijndaelManaged();
CryptoStream cs = new CryptoStream(fsCrypt,RMCrypto.CreateEncryptor(key, key),CryptoStreamMode.Write);
FileStream fsIn = new FileStream(inputFile, FileMode.Open);
int data;
while ((data = fsIn.ReadByte()) != -1)
cs.WriteByte((byte)data);
fsIn.Close();
cs.Close();
fsCrypt.Close();
}
catch
{
MessageBox.Show("Encryption failed!", "Error");
}
}
무엇이 오류입니까? –
암호화가 실패했다고 표시됩니다. – SoftwareDeveloper
... 당신이 예외를 먹기 때문입니다. 디버깅 목적으로 try-catch를 제거하거나 모든 예외를 catch하도록 catch 절을 변경하고 (catch (Exception ex)), 중단 점을 설정하고 예외를 검사하십시오. – CodeCaster