1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Fixed issue where both key and iv aren't stored for upload and it would try to decrypt it.

This commit is contained in:
Uncled1023 2016-01-27 19:54:04 -08:00
parent c3774bd811
commit 7806555a07
2 changed files with 10 additions and 5 deletions

View File

@ -93,7 +93,7 @@ namespace Teknik.Areas.API.Controllers
string fullUrl = Url.SubRouteUrl("upload", "Upload.Download", new { file = upload.Url });
var returnData = new
{
url = (saveKey) ? fullUrl : fullUrl + "#" + key,
url = (saveKey && !string.IsNullOrEmpty(key)) ? fullUrl : fullUrl + "#" + key,
fileName = upload.Url,
contentType = contentType,
contentLength = contentLength,

View File

@ -119,11 +119,16 @@ namespace Teknik.Areas.Upload.Controllers
if (System.IO.File.Exists(upload.FileName))
{
// Read in the file
byte[] encData = System.IO.File.ReadAllBytes(upload.FileName);
// Decrypt the data
byte[] data = AES.Decrypt(encData, upload.Key, upload.IV);
byte[] data = System.IO.File.ReadAllBytes(upload.FileName);
// Create File
// If the IV is set, and Key is set, then decrypt it
if (!string.IsNullOrEmpty(upload.Key) && !string.IsNullOrEmpty(upload.IV))
{
// Decrypt the data
data = AES.Decrypt(data, upload.Key, upload.IV);
}
// Create content disposition
var cd = new System.Net.Mime.ContentDisposition
{
FileName = upload.Url,