在64位模式下运行时,您可以生成一个x86的哈希值? [英] Can you generate an x86 hash value when running in x64 mode?

查看:199
本文介绍了在64位模式下运行时,您可以生成一个x86的哈希值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是有点这个星期,当我的代码在64位进程托管所发生的错误。我使用查找哈希值,我存储在数据库中的哈希值。已在过去已经生成的散列值是一个86哈希和现在正在生成的64位散列我收到错误,因为查找值不要再相匹配。

I was bit this week by a bug that occurred when my code was hosted in an x64 process. I am using a hash value for lookup and I am storing that hash value in a database. The hash value that has been generated in the past was a x86 hash and now that x64 hashes are being generated I am getting errors because the lookup values don't match anymore.

我高度怀疑这一点,但我想我会问反正。有没有一种方式,如果我的代码是在64位进程中运行,生成一个x86的哈希值?

I am highly skeptical of this, but I thought I'd ask anyway. Is there a way to generate an x86 hash value if my code is running in an x64 process?

有关参考,我在.NET 4.0上运行使用C#。

For reference, I am running on .NET 4.0 using C#.

编辑:

下面是我已经运行到的问题:的字符串的GetHashCode返回的值不同

Here's the problem I've been running into: String GetHashCode returns different values

您可以复制创建一个问题用下面的代码控制台应用程序:

You can duplicate the problem by creating a console app with the following code:

"DDD.Events.Application.ApplicationReferenceCreated".GetHashCode()

运行与x86平台应用程序,然后使用x64平台上运行它。

Run the app with x86 platform, then run it with the x64 platform.

我只是想跨平台获得一致的价值观。不过,我可能只是创建哈希预编译的列表,以便我可以在我需要时故障转移。我只是想知道是否有一种方法来的GetHashCode获得一致的值()。我不这么认为,但如果可能的话这将是我的情况下,最简单的解决方案。

I just want to get consistent values across platforms. However, I may just create a pre-compiled list of hashes so I can fail over in the event I need to. I just wanted to know if there were a way to get consistent values from GetHashCode(). I don't think so, but if it is possible it would be the easiest solution in my case.

推荐答案

我害怕,如果你正在使用.NET中的默认实现,那么这是不可能的。他们甚至不保证它会返回不同版本的.NET之间的相同的ID;并明确说明它不能被用来作为唯一的标识符。
对此有读MSDN上

I'm afraid if you are using the default implementation in .NET then this is not possible. They do not even guarantee it will return the same id between different versions of .NET; and explicitly state it must not be used as a unique identifier. Have a read of this on MSDN

这篇关于在64位模式下运行时,您可以生成一个x86的哈希值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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