English 中文(简体)
1. Hash a ID to a Random x,y coordinated within a Border平方
原标题:Hash an ID to a Random x,y coordinate within a boundary square
  • 时间:2010-12-05 21:49:07
  •  标签:
  • hash

我有一个界定的地区(我知道该地区每个角落的Xy坐标)。 我需要把一个身份证(粗体或焦炭阵列)贴到位于该边界地区的Xy点。 由此而产生的 ha价值,即x,y co-ordinations,需要独一无二,最好是我不想把x,y点集中到一片广场,而是在广场上分配。

关于我如何能够做到这一点的任何建议?

很多人预先表示感谢。

问题回答

首先,我不认为你可以保证独一无二。 如果有<代码>maxX*maxY+1 身份识别器,你一定会拥有两个身份识别器。

其次,为了避免集群,使用加密安全带。

第三,获得x和坐标(粗略为/假装):

 hashResult = hash(ID)
 x = hashResult modulo maxX.
 y = ( hashResult div maxX) modulo maxY




相关问题
hmac-sha1 in ruby differs from C# HMACSHA1

I am trying to test the API from ankoder.com and have problem on the digest calculation for the authentication token . The sample is ruby while I am trying to call from C#. When I compare the digest ...

Make md5 strong

Im making a website that will intergrate with game that only support md5 hashing metod (atm). Which ofc is not especially safe anymore. But how could i make it stronger? Should I just generate long ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Utility to hash and list files with identical contents?

UltraEdit saves temporary, ie. unsaved/untitled, files as (regex) "Edit.d+". When UltraEdit is killed (I do this when some software nags me to reboot), I noticed that it doesn t always save files in ...

How can I assign multiple values to a hash key?

For the sake of convenience I am trying to assign multiple values to a hash key in Ruby. Here s the code so far myhash = { :name => ["Tom" , "Dick" , "Harry"] } Looping through the hash gives a ...

Concurrent modification whilst traversing a ruby Hash

Suppose you had this: def wipeProduct(hash, nameToDelete) hash.each do |i| key = i[0] productName = i[1].first hash.delete(key) if productName==nameToDelete end end I m not sure it ...

Ruby (RoR) XML to hash and then show in views

I have some xml on server (http://server.com/my.xml). Here is the example: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE current PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3....

热门标签