简体   繁体   English

当我加密文件时,如何防止文件的图标被加密?

[英]When i encrypt a file, how can prevent the file's icon from being encrypted?

I am writing a simple software protection tool which works by reading the input file as array of bytes, then encrypts this array of bytes using AES, and store the result into another file which is responsible to decrypt itself. 我正在编写一个简单的软件保护工具,它通过将输入文件作为字节数组读取,然后使用AES加密这个字节数组,并将结果存储到负责解密自身的另一个文件中。

Till now, the software works like a charm, but there's only one problem, is that when i encrypt a file, the output file ( protected file ) lose it's icon, i think because all the file's resources are encrypted. 到目前为止,该软件就像一个魅力,但只有一个问题,就是当我加密文件时,输出文件(受保护文件)丢失了它的图标,我认为因为所有文件的资源都是加密的。 And therefore the icon is no longer available. 因此图标不再可用。

I tried to use a class which is written in my previous question to change the file's icon after encrypting it, but it seems that is doesn't work with the encrypted file even it works correctly with any other exe file. 我尝试使用在我之前的问题中编写来加密它后更改文件的图标,但它似乎对加密文件不起作用,即使它与任何其他exe文件一起正常工作。

So in order to make this works, i decided to first change the input file's icon, then ENCRYPT THE FILE WHITHOUT ENCRYPTING IT'S ICON 所以为了使这个工作,我决定先改变输入文件的图标,然后加密文件,加强它的图标

This should work, if i can only strip the icon's resources from being encrypted. 如果我只能剥离图标的资源加密,这应该可行。

How can prevent the input file's icon from being encrypted ? 如何防止输入文件的图标被加密?

You may encrypt the .exe and append the encrypted data to an existing .exe with the same icon. 您可以加密.exe并将加密数据附加到具有相同图标的现有.exe。 That icon may also perform the decryption. 该图标也可以执行解密。 You should supply the key from outside though. 你应该从外面提供钥匙。

Extract the icon from the input file 从输入文件中提取图标

Store it in the memory 将其存储在内存中

Encrypt the file 加密文件

Add your icon (as a resource) and the encrypted file to a new exe. 将您的图标(作为资源)和加密文件添加到新的exe。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM