简体   繁体   English

创建并签名自定义文件类型

[英]creating and signing a custom file type

I believe this is going to be a big question but I searched the web for at least an hour for an answer and I hope here I'll get the answer. 我相信这将是一个很大的问题,但是我在网上搜索了至少一个小时的答案,希望在这里得到答案。
So the thing is I want to create my own file extension that will essentially be a binary file that my program will obviously will know how to interpret. 因此,我想创建自己的文件扩展名,该扩展名本质上将是一个二进制文件,程序显然会知道该如何解释。
I know how to create a binary file and read from it, I understood that all I need is to change the extension and check it before I start reading the file. 我知道如何创建二进制文件并从中读取文件,我知道我所需要的只是更改扩展名并在开始读取文件之前对其进行检查。

The question is even if I create my own extension and check for it before start reading, I can't know that the file was really created by my application, someone could just change the extension and my application won't get the data it needs (of course I'll put everything in a try and catch so the application won't crush). 问题是,即使我创建了自己的扩展名并在开始阅读之前进行了检查,我也不知道该文件确实是由我的应用程序创建的,有人可以更改扩展名,而我的应用程序将无法获取所需的数据(当然,我会尽一切努力使应用程序不会崩溃)。

Is there a way to sign a binary file before opening it so people that get the file can know that my application created that file and not something that someone changed to look like my file type? 有没有一种方法可以在打开二进制文件之前对它进行签名,以便获得该文件的人可以知道我的应用程序创建了该文件,而不是别人更改为类似于我的文件类型的文件?

It's more of an idea I have so I don't have any code to show or any example other than this scenario. 这是我的一个主意,因此除了这种情况之外,我没有任何要显示的代码或任何示例。
All I need is something that people will know came from me and not something that every other person can generate on his own (not talking about programmers, I'm talking about regular people). 我需要的是人们会知道的东西,而不是其他每个人都可以自己产生的东西(不是在谈论程序员,而是在谈论普通人)。

If you know anything about this subject please direct me to the answer or if you know post it here. 如果您对此主题有任何了解,请直接给我答案,或者如果您知道将其发布在这里。

One way could be to encrypt the contents of the file, then have your application decrypt it. 一种方法是加密文件的内容,然后让应用程序对其进行解密。

Anyone opening the file in your application would immediately know if that application generated it. 任何在您的应用程序中打开文件的人都会立即知道该应用程序是否生成了该文件。

我会在文件的开头(文件头)创建一个特殊的序列

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

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