Secure Password Hashing [closed]

Salt your hash with secure random salt of at least 128bits or longer, to avoid a rainbow attack and use BCrypt, PBKDF2 or scrypt. PBKDF2 comes with NIST approval. To quote: Archive.org: http://chargen.matasano.com/chargen/2007/9/7/enough-with-the-rainbow-tables-what-you-need-to-know-about-s.html The problem is that MD5 is fast. So are its modern competitors, like SHA1 and SHA256. Speed is a design goal of … Read more

Can I depend on the values of GetHashCode() to be consistent?

If I’m not mistaken, GetHashCode is consistent given the same value, but it is NOT guaranteed to be consistent across different versions of the framework. From the MSDN docs on String.GetHashCode(): The behavior of GetHashCode is dependent on its implementation, which might change from one version of the common language runtime to another. A reason … Read more

Why can hashCode() return the same value for different objects in Java?

hashing an object means “finding a good, descriptive value (number) that can be reproduced by the very same instance again and again“. Because hash codes from Java’s Object.hashCode() are of type int, you can only have 2^32 different values. That’s why you will have so-called “collisions” depending on the hashing algorithm, when two distinct Objects … Read more

Comparing ruby hashes [duplicate]

here is a slightly modified version from colin’s. class Hash def diff(other) (self.keys + other.keys).uniq.inject({}) do |memo, key| unless self[key] == other[key] if self[key].kind_of?(Hash) && other[key].kind_of?(Hash) memo[key] = self[key].diff(other[key]) else memo[key] = [self[key], other[key]] end end memo end end end It recurses into the hashes for more efficient left and right {a: {c: 1, b: … Read more

Compute a hash from a stream of unknown length in C#

MD5, like other hash functions, does not require two passes. To start: HashAlgorithm hasher = ..; hasher.Initialize(); As each block of data arrives: byte[] buffer = ..; int bytesReceived = ..; hasher.TransformBlock(buffer, 0, bytesReceived, null, 0); To finish and retrieve the hash: hasher.TransformFinalBlock(new byte[0], 0, 0); byte[] hash = hasher.Hash; This pattern works for any … Read more

Performance of Arrays and Hashes in Ruby

Hashes are much faster for lookups: require ‘benchmark’ Document = Struct.new(:id,:a,:b,:c) documents_a = [] documents_h = {} 1.upto(10_000) do |n| d = Document.new(n) documents_a << d documents_h[d.id] = d end searchlist = Array.new(1000){ rand(10_000)+1 } Benchmark.bm(10) do |x| x.report(‘array’){searchlist.each{|el| documents_a.any?{|d| d.id == el}} } x.report(‘hash’){searchlist.each{|el| documents_h.has_key?(el)} } end # user system total real #array 2.240000 … Read more

Asking “is hashable” about a Python value

Python 3.x Use collections.abc.Hashable or typing.Hashable. >>> import typing >>> isinstance({}, typing.Hashable) False >>> isinstance(0, typing.Hashable) True Note: both are the same one, the latter is simply an alias of the former. Also note that collections.Hashable was removed in Python 3.10+ (deprecated since 3.7). Python 2.6+ (an original answer) Since Python 2.6 you can use … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)