产生安全散列code为objectgraph [英] generating an safe hashcode for an objectgraph

查看:122
本文介绍了产生安全散列code为objectgraph的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从文件导入一些数据(XLS,CSV,XML)至极,将导致一个复杂的内存对象图。现在我需要知道这个图是否已被修改,因为它曾经是出口。什么将是一个安全的方法来检查呢?我想我会导出一个哈希code的文件吗?如果是的话会<一href="http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethash$c$c">the产生一个对象的哈希值code 足够的标准方法?我应该如何生成散列?我将preFER生成对象图上的散列而非实际的流/文件

I am importing some data from an file (xls, csv, xml) wich will result in a complex in-memory object graph. Now I need to know whether this graph has been modified since it once was exported. What would be a safe way to check this? I suppose I'd export a hashcode with the file? If so would the standard way of generating an object's hashcode suffice? How should I generate the hash? I would prefer to generate the hash on the object graph rather than on the actual stream/file.

推荐答案

我最后做以下(至极似乎工作pretty的好):

I ended up doing the following (wich seems to work pretty well):

  1. 创建一个自定义的整数哈希code,其中包括一个对象的所有简单属性使用<一个href="http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethash$c$c">this算法。
  2. 所有复杂的对象重复1.此对象引用
  3. 在一个众所周知的顺序序列化所有整数哈希code到一个二进制流
  4. 创建该流的MD5校验
  1. create a custom integer hashcode that include all simple properties of a single object using this algorithm.
  2. repeat 1. for all complex objects that this object references
  3. serialize all integer hashcode into one binary stream in a well known order
  4. create a MD5 checksum of this stream

这篇关于产生安全散列code为objectgraph的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆