hash

How to use a 'subroutine reference' as a hash key

。_饼干妹妹 提交于 2020-01-04 16:57:11
问题 In Perl, I'm learning how to dereference 'subroutine references'. But I can't seem to use a subroutine reference as a hash 'key'. In the following sample code, I can create a reference to a subroutine ($subref) and then dereference it to run the subroutine (&$subref) I can use the reference as a hash 'value' and then easily dereference that But I cannot figure out how to use the reference as a hash 'key'. When I pull the key out of the hash, Perl interprets the key as a string value (not a

What does “no collisions have been found yet for this hashing method” even mean?

╄→尐↘猪︶ㄣ 提交于 2020-01-04 14:21:10
问题 I mean I don't need to look for the actual collisions, to know they exist. If there weren't collisions, then how would you have fixed-length results? That's why I don't understand what people mean when they claim 'md5 is insecure! someone found collisions!', or something like that. The only thing I can think of, is that the collision search only looks for dictionary words, eg: If 'dog' and 'house' share the same hash, it would be a stupid hashing method IMO. It could also look for strings

What does “no collisions have been found yet for this hashing method” even mean?

我与影子孤独终老i 提交于 2020-01-04 14:21:07
问题 I mean I don't need to look for the actual collisions, to know they exist. If there weren't collisions, then how would you have fixed-length results? That's why I don't understand what people mean when they claim 'md5 is insecure! someone found collisions!', or something like that. The only thing I can think of, is that the collision search only looks for dictionary words, eg: If 'dog' and 'house' share the same hash, it would be a stupid hashing method IMO. It could also look for strings

Password hashing - Industry Standards

爷,独闯天下 提交于 2020-01-04 13:59:50
问题 I know there are probably a lot of questions like this already. But, I really haven't found the definite answer for my question. I know that passwords are stored in the database with a prepended random salt followed by the hashed password. The value of the password is actually never known (by the server and thus the server admins). What is the standard hashing algorithm ? I know cryptography is a dynamic field and changes with time. So I'm asking what's the current industry standard for

Convenient way of obtaining the specific object being used for a key in a hash in Ruby?

徘徊边缘 提交于 2020-01-04 06:43:20
问题 Here's an interesting one, I have a scenario in a bucket sharding system I'm writing where I maintain index hashes and storage hashes, the interrelation is a UUID generated because this is distributed and I want some confidence that new buckets gain unique references. Early on in this exercise I started optimising the code to freeze all keys generated by SecureRandom.uuid (it produces strings) because when you use a string as a key in a hash gets duped and frozen automatically to ensure that

what is sketch method doing in RangePartitioner of Spark

南笙酒味 提交于 2020-01-04 06:26:24
问题 I was reading the source code of apache spark. And i got stuck at logic of Range Partitioner's sketch method. Can someone please explain me what exactly is this code doing? // spark/core/src/main/scala/org/apache/spark/Partitioner.scala def sketch[K:ClassTag](rdd: RDD[K], sampleSizePerPartition: Int): (Long, Array[(Int, Int, Array[K])]) = { val shift = rdd.id // val classTagK = classTag[K] // to avoid serializing the entire partitioner object val sketched = rdd.mapPartitionsWithIndex { (idx,

what is sketch method doing in RangePartitioner of Spark

扶醉桌前 提交于 2020-01-04 06:26:05
问题 I was reading the source code of apache spark. And i got stuck at logic of Range Partitioner's sketch method. Can someone please explain me what exactly is this code doing? // spark/core/src/main/scala/org/apache/spark/Partitioner.scala def sketch[K:ClassTag](rdd: RDD[K], sampleSizePerPartition: Int): (Long, Array[(Int, Int, Array[K])]) = { val shift = rdd.id // val classTagK = classTag[K] // to avoid serializing the entire partitioner object val sketched = rdd.mapPartitionsWithIndex { (idx,

Calculating SHA1 hash of a 'nvarchar' string using T-SQL

时光怂恿深爱的人放手 提交于 2020-01-04 06:06:18
问题 I'm trying to calculate SHA1 hash of a unicode string using T-SQL. The below code works fine with ASCII strings: declare @input varchar(50) set @input = 'some text' print 'SHA1 Hash: ' + UPPER(master.dbo.fn_varbintohexsubstring(0, HashBytes('SHA1', @input), 1, 0)) but it calculates wrong hash when I replace first line of code with declare @input nvarchar(50) . Calculated hash (nvarchar): BBA91B680CE2685E9465DE24967E425CF055B10F Calculated hash by a tool :

Calculating SHA1 hash of a 'nvarchar' string using T-SQL

*爱你&永不变心* 提交于 2020-01-04 06:05:45
问题 I'm trying to calculate SHA1 hash of a unicode string using T-SQL. The below code works fine with ASCII strings: declare @input varchar(50) set @input = 'some text' print 'SHA1 Hash: ' + UPPER(master.dbo.fn_varbintohexsubstring(0, HashBytes('SHA1', @input), 1, 0)) but it calculates wrong hash when I replace first line of code with declare @input nvarchar(50) . Calculated hash (nvarchar): BBA91B680CE2685E9465DE24967E425CF055B10F Calculated hash by a tool :

Generate shorter public id

流过昼夜 提交于 2020-01-04 06:04:00
问题 I am looking for a way to generate public ids for my objects (like a facebook uid). The id should be unique and the user should not be able to guess it (or the next one). Right now I am using this: sha1('a fixed random string' . $this->getId()) The problem is that sha1 generates very long strings (40 chars) and I would like it to be shorter. I thought about using MD5 but it's known to be not save because you can create collisions. Is this really a problem in my case? What alternatives do I