1

I am using protobuf-net to encrypt, serialize and store the contents of an object into a file and am using contents of the file after decrypting and desiralizing into the original object.

The object can be decrypted, and deserialized perfectly through my application on the machine on which it was created but when the exact same application reads the exact same file when executed on another machine, it throws an exception asking me to refer to one of the existing questions on stackoverflow. I am unable to post the exact stacktrace right now but will be doing so shortly.

My question is - does the physical configuration of the machine on which the serialization and storage of an object into a file takes place have any bearing on its availability elsewhere?

I think this should not be the case as it would defeat the purpose of serialization and that there is a gap in my understanding.

All help is sincerely appreciated.

Thanks!

EDIT:

Thanks Marc! - for both the reply and the awesome library itself. I'll post back more details regarding the stack trace, the encryption technique used, and the length and bytes of the contents. Though I doubt that there is a problem in the encryption/decryption code logic since the same code creates and uses the file successfully on one machine. Overwriting an existing file can also be ruled out as the created files are named using a guid so the name getting repeated is improbable. Could you please clarify on what exactly you mean by "by treating the file as text at some point"?

4

1 回答 1

0

不,不应该对机器配置有任何依赖。例如,在常规 .net 上序列化数据然后在 windows phone 上反序列化它是完全合理的,或者在浏览器中的 unity 上通过 MonoTouch 在 iOS 上反序列化它是完全合理的。

那么,我首先关心的是它是否真的是“完全相同的文件”。特别是解密(因为一些加密技术确实使用机器配置,但这与protobuf-net无关)

我强烈建议在解密后检查长度和字节(或者如果它很大,则使用散列函数)。常见错误:

  • 您的加密/解密代码中的错误
  • 用更少的数据覆盖预先存在的文件,最后留下旧垃圾(在这种情况下:一定要截断文件)
  • 在机器之间传输文件时损坏,例如在某些时候将文件视为文本

如果您有一个可重复的示例(在这里,或者如果您无法在此处公开发布,则通过电子邮件),可能会说更多。

于 2012-10-26T14:59:24.267 回答