djd*_*d87 12 encryption serialization compact-framework protocol-buffers .net-2.0
我已将我的移动设备上的数据库迁移远离VistaDB,因为它太慢了.我现在使用ProtoBuf在存储卡上创建一系列平面文件,唯一的问题是显然没有加密.
哪种加密方法最适合ProtoBuf?我基本上将一组数据实体序列化到一个文件中,然后从File反序列化回到我的集合中.我认为加密的最佳位置是在读/写的FileStream中.
数据将包含NI编号,名称和地址,因此必须是安全的.任何想法的人?
我认为你走在正确的道路上。你应该能够做类似的事情:
\n\nICryptoTransform encryptor = ...\nStream encStream = new CryptoStream(outputFileStream, encryptor, CryptoStreamMode.Write);\nSerializer.Serialize(encStream, obj);\nencStream.FlushFinalBlock()\nencStream.Close();\n\nICryptoTransform decryptor = ...\nStream decStream = new CryptoStream(inputputFileStream, decryptor, CryptoStreamMode.Read);\nSerializer.Deserialize<Type>(decStream);\ndecStream.FlushFinalBlock()\ndecStream.Close();\nRun Code Online (Sandbox Code Playgroud)\n\n有关 .NET 加密框架的基础知识(包括如何获取 ICryptoTransform 对象),请参阅其他问题,例如What\xe2\x80\x99s the best way to encrypt Short strings in .NET?。
\n| 归档时间: |
|
| 查看次数: |
6849 次 |
| 最近记录: |