Как зашифровать данные с URL-адреса
Привет,
Любой может помочь мне, как зашифровать данные из взятия URL, я написал ниже код и вызываю зашифрованный файл в основной функции, но я не могу прочитать входной файл в то время как ...
Что я уже пробовал:
Class AES { public void EncryptFile(string inputFile, string outputfile, string hoskeys) { try { //if(!File.Exists(outputfile)) // File.Create(outputfile); // Create the password key byte[] saltValueBytes = Encoding.ASCII.GetBytes("This is my salt"); Rfc2898DeriveBytes passwordKey = new Rfc2898DeriveBytes(hoskeys, saltValueBytes); // Create the algorithm and specify the key and IV RijndaelManaged alg = new RijndaelManaged(); alg.Key = passwordKey.GetBytes(alg.KeySize/8); alg.IV = passwordKey.GetBytes(alg.BlockSize/8); // Read the unencrypted file into fileData FileStream inFile = new FileStream(inputFile, FileMode.Open, FileAccess.Read); byte[] fileData = new byte[inFile.Length]; inFile.Read(fileData, 0, (int)inFile.Length); // Create the ICryptoTransform and CryptoStream object ICryptoTransform encryptor = alg.CreateEncryptor(); FileStream outFile = new FileStream( outputfile, FileMode.OpenOrCreate, FileAccess.Write); CryptoStream encryptStream = new CryptoStream(outFile, encryptor, CryptoStreamMode.Write); // Write the contents to the CryptoStream encryptStream.Write(fileData, 0, fileData.Length); // Close the file handles encryptStream.Close(); inFile.Close(); outFile.Close(); } catch(Exception ex) { //MessageBox.Show("Encryption failed!", "Error"); Console.WriteLine(""); } } //calling in main function Encrypt_and_decrypt.AES e = new AES(); e.EncryptFile("http://192.168.....","E:\\folder","hkeys");
F-ES Sitecore
Файловый поток предназначен для доступа к файлам в файловой системе, он не понимает http, поэтому вы не можете получить доступ к файлам через http. Если вы хотите прочитать файл по протоколу http вам понадобится что то вроде
https://msdn.microsoft.com/en-us/library/ez801hhe(v=против 110).aspx
или
https://social.msdn.microsoft.com/Forums/en-US/b489fe1d-a237-48ac-b58a-f901e1b03bde/file-download-how-to-use-httpwebrequestrespone?форум=vssmartdevicesvbcs