CRC32 vs CRC32C?

The CRC32 found in zip and a lot of other places uses the polynomial 0x04C11DB7; its reversed form 0xEDB88320 is perhaps better known, being often found in little-endian implementations. CRC32C uses a different polynomial (0x1EDC6F41, reversed 0x82F63B78) but otherwise the computation is the same. The results are different, naturally. This is also known as the … Read more

What is a good 64bit hash function in Java for textual strings?

Why don’t you use a long variant of the default String.hashCode() (where some really smart guys certainly put effort into making it efficient – not mentioning the thousands of developer eyes that already looked at this code)? // adapted from String.hashCode() public static long hash(String string) { long h = 1125899906842597L; // prime int len … Read more

How can I hash passwords in postgresql?

It’s been a while since I asked this question, and I’m much more familiar with the cryptographic theory now, so here is the more modern approach: Reasoning Don’t use md5. Don’t use a single cycle of sha-family quick hashes. Quick hashes help attackers, so you don’t want that. Use a resource-intensive hash, like bcrypt, instead. … Read more

What is default hash algorithm that ASP.NET membership uses?

EDIT: Do not use the Membership Provider as-is because it is horridly inadequate in terms of protecting user’s passwords In light of the fact that googling “membership provider hashing algorithm” turns up this answer as the first result, and the gospel that will be inferred, it behoves me to warn folks about using the Membership … Read more

Obtain SHA-256 string of a string

The implementation could be like that public static String sha256_hash(String value) { StringBuilder Sb = new StringBuilder(); using (SHA256 hash = SHA256Managed.Create()) { Encoding enc = Encoding.UTF8; Byte[] result = hash.ComputeHash(enc.GetBytes(value)); foreach (Byte b in result) Sb.Append(b.ToString(“x2”)); } return Sb.ToString(); } Edit: Linq implementation is more concise, but, probably, less readable: public static String sha256_hash(String … Read more

TypeError: unhashable type: ‘dict’, when dict used as a key for another dict [duplicate]

From the error, I infer that referenceElement is a dictionary (see repro below). A dictionary cannot be hashed and therefore cannot be used as a key to another dictionary (or itself for that matter!). >>> d1, d2 = {}, {} >>> d1[d2] = 1 Traceback (most recent call last): File “<input>”, line 1, in <module> … Read more

How to generate hash number of a string in Go?

The hash package is helpful for this. Note it’s an abstraction over specific hash implementations. Some ready made are found in the package subdirectories. Example: package main import ( “fmt” “hash/fnv” ) func hash(s string) uint32 { h := fnv.New32a() h.Write([]byte(s)) return h.Sum32() } func main() { fmt.Println(hash(“HelloWorld”)) fmt.Println(hash(“HelloWorld.”)) } (Also here) Output: 926844193 107706013

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