Android 中的签名和发送文件
首先是一些背景知识。
我有一个文件,为了简单起见,我们将其命名为 test.txt。我想签署这个文件并将其发送到服务器,服务器将验证签名并解密它。服务器已经有我的公钥,所以不需要发送它。
到目前为止,我已经能够为我想要发送的数据生成签名(我的代码看起来与此示例完全相同: GenSig.java)。但该示例创建了一个签名文件,这意味着我需要发送两个文件:sig 文件和 test.txt。我的问题是,我可以在不创建两个单独的文件的情况下执行此操作吗?理想情况下,我只想发送一个文件,最后包含数据和签名。
First some background.
I have a file, for simplicity's sake, let's call it test.txt. I want to sign this file and sent it over to the server, which will verify the signature and decrypt it. The server has my public key already so there's no need to send that.
So far, I've been able to generate a signature for the data I want to send(My code looks exactly like this example: GenSig.java). But the example creates a signature file, which means I have two files I need to send, the sig file and test.txt. My question is, can I do this without creating two separate files? I would ideally like to sent just one file with the data and the signature at the end.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,这毕竟是一个愚蠢的问题。合并两个文件将导致第一个文件被修改!因此无论如何签名数据都不会匹配。答案是,不,你不能将它们结合起来。您正在更改文件,并试图证明该文件在传输过程中没有被更改! (除非我将两者都以 zip 文件形式发送,但我不想走这条路)。我想是两个文件!
Well, this was a silly question after all. Combining the two files will result in the first file being modified! Therefore the signature data won't match no matter what. The answer is, no, you can't combine them. You are altering the file you are trying to prove hasn't been altered in the course of transit! (Unless I send both in a zip file but I don't want to go down that path). I suppose two files it is!