簡體   English   中英

從圖像的加密數據字節中獲取失真/加密的圖像

[英]Get the distorted/encrypted image from encrypted data bytes of an image

我已經使用簡化的DES加密了圖像文件(.jpeg / .png)的數據字節。 但是,加密后,圖像文件將無法重新轉換為圖像,因為它丟失了其原始文件結構。 有什么方法可以使用這些加密的數據字節轉換為圖像文件? 這是我的C#代碼的一瞥:

        Console.WriteLine("Please enter the RGB/GRAY/BINARY image path: ");
        string path = Console.ReadLine();
        byte []arrayPT = Conversion.Convert.ImageToBinary(path); // Get the binary data             
        byte []arrayCT = new byte[arrayPT.Length];
        int i = 0;
        foreach (byte element in arrayPT)
        {
            arrayCT[i] = ob.Encrypt(element); 
        /* I want to use the contents of the arrayCT[] and convert to an image */
            Console.Write("{0}", arrayCT[i]);
            i++;
        }

使用當前的方法,您正在將圖像標題和內容一起加密,它將不再被視為圖像。

如果您不需要隱藏它是圖像也不是寬度×高度的事實,那么我將采取以下方法:

  1. 將原始圖像放入位圖對象
  2. 這應該使您可以將已解壓縮的圖像作為字節數組(Bitmapdata)進行訪問
  3. 加密字節數組
  4. 創建一個與原始寬度和高度相同的新Bitmap對象
  5. 將加密的字節導入新的位圖字節
  6. 以與輸入圖像相同的格式將圖像保存在新文件中

檢查Bitmapdata ,了解有效處理圖像字節的方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM