hash

Are the first 32 bits of a 160-bit SHA1 hash an acceptable substitute for a CRC32 hash?

十年热恋 提交于 2019-12-22 06:27:20
问题 I'm working on a .NET 3.5 project and I need a 32-bit hash value. There doesn't seem to be any methods in the .NET Cryptography classes that return a 32-bit hash (MD5 is 128 bits, SHA1 is 160 bits, etc.). I implemented a CRC32 class, but I find that the SHA1 and MD5 hashing functions that already exist are much faster. Would there be any problem (i.e., increased chance of collisions) with me using the SHA1 hashing function and just breaking off the first 32 bits to store as my hash value? 回答1

When does __eq__ gets called using hash()?

烂漫一生 提交于 2019-12-22 05:47:17
问题 As mentioned here, Below code, class Person(object): def __init__(self, name, ssn, address): self.name = name self.ssn = ssn self.address = address def __hash__(self): print('in hash') return hash(self.ssn) def __eq__(self, other): print('in eq') return self.ssn == other.ssn bob = Person('bob', '1111-222-333', None) jim = Person('jim bo', '1111-222-333', 'sf bay area') dmv_appointments = {} print('calling hash') dmv_appointments[bob] = 'tomorrow' print('calling hash') print(dmv_appointments

How to hash vectors into buckets in Locality Sensitive Hashing (using jaccard distance)?

一曲冷凌霜 提交于 2019-12-22 05:42:13
问题 I am implementing a near-neighbor search application which will find similar documents. So far I have read a good portion of LSH related materials (theory behind LSH is some kind of confusing and I am not able to comphrened it 100% yet). My code is able to compute the signature matrix using the minhash functions (I am close to the end). I also apply the banding strategy on the signature matrix. However I am not able to understand how to hash signature vectors (of columns) in a band into

How can I do an ISO 9797-1 MAC with triple DES in C#?

萝らか妹 提交于 2019-12-22 05:18:04
问题 I've got a project which stipulates the following encryption rules for a 24 byte block of data. 1) Cryptography should be done using full triple DES MAC algorithm as defined in 9797-1 as MAC algorithm 3 with output transformation 3 without truncation and with DES in CBC mode as block cipher with ICV set to zeros. Last 8 bytes of encrypted data constitute the value we need. The program is saying the encryption done is wrong. Are there any other things I need to do to match the above spec? The

Insert hashed bundle URLs into static pug templates

早过忘川 提交于 2019-12-22 04:56:20
问题 I'm using Webpack pug-html-loader + file-loader to generate a bunch of static pug templates. I also want to start added hashed bundle filenames, but I cant work out how to insert the hashed filenames into all my pug templates This is how I'm referencing my bundle currently in all the pug templates: script(src="bundle.js") link(href="bundle.css") How would I modify that to reference bundle-[chunkhash].js / bundle-[chunkhash].css] - do I need to pass some variables to the pug-html-loader in

Laravel 4 - Hashing same password gives different values

我只是一个虾纸丫 提交于 2019-12-22 04:53:11
问题 I am trying to authenticate a user using the Auth::attempt() method and it keeps failing, so I eventually ended up with the following code: $arr = array(); $arr['verified'] = Hash::make('1234') . ' ; ' . Hash::make('1234'); return json_encode($arr); and this is the result: {"verified":"$2y$10$V4yXBUcxealfLrzOE\/xAD.sJ8qpNhrMA6K6dENBBXYqaVx1zSETgy ; $2y$10$C9xpOWLTUyfy1KL.Y3Tot.KWADmQYFK\/HAf6uZGGXTKcVh52qHS4m"} As you can see, the first hash gives $2y$10$V4yXBUcxealfLrzOE\/xAD

Password hash and salting - is this a good method?

天涯浪子 提交于 2019-12-22 04:42:05
问题 I was doing a little research or googling for different methods of handling password hashing and salting and came across this interesting link: http://phix.me/salt/ Now, essentially what this proposes is the creation of two user functions, one for hashing and one for checking the hash. The salt is pseudo random but is in actual fact based upon the password (strikes me as bad?). The hashing function also pseudo randomly "sprinkles" the salt amongst the hash string. The hash checking function

Inconsistent implicit hash creation in Ruby?

♀尐吖头ヾ 提交于 2019-12-22 04:32:14
问题 Ok, so I was comparing some stuff in my own DSL to Ruby. One construct they both support is this x=["key" => "value"] Knowing the difference between arrays and hashes, I would think this to be illegal, but the result in Ruby is [{"key" => "value"}] Why is this? And with this kinda syntax why can't you do x=("key" => "value") Why is an array a special case for implicitly created hashes? 回答1: Another special case is in a function call, consider: def f(x) puts "OK: #{x.inspect}" end f("foo" =>

Check if huge list in python has changed

荒凉一梦 提交于 2019-12-22 04:27:14
问题 In short: what's the fasted way to check if a huge list in python has changed? hashlib needs a buffer, and building a string representation of that list is unfeasible. In long: I've got a HUGE list of dictionaries representing data. I run a number of analyses on this data, but there are a few meta-data aspects that are required by all of the analyses, ie. the the set of subjects (each dict in the list has a subject key, and at times I just need a list of all subject who have data present in

Hash Function with Order Preserving

女生的网名这么多〃 提交于 2019-12-22 04:19:12
问题 Is there any hash function with uniq hash code (like MD5) with order preserving? NOTE: i don't care about security, i need it for sorting, i have lot of chunks with (~1MB size) and i want to sort them, of course i can use index sort but i want to reduce time of compare Theoreticaly: if i have 1'000'000 chunks with 1MB size (1'048'576 byte) and all of them have difference in last 10 bytes then time of compare of one chunk to other will be O(n-10) and if i will use QuictSort (which make ~(n