string-hashing

Hash function to produce a code of 30 chars?

给你一囗甜甜゛ 提交于 2021-02-07 03:54:51
问题 I need to hash a message into a string of 30 chars. What's the best and most secure hash function for this usage? 回答1: Thirty characters (bytes) is 240 bits. If you can't move the goal-post to allow 32 characters, then you will probably end up using SHA-1, which generates 160-bits or 20 bytes. When Base-64 encoded, that will be 28 characters. If you use a hex-encoding, it will be 40 characters, which is nominally out of range. With 32 characters, you could use SHA-256, but Base-64 encoding

Hash function to produce a code of 30 chars?

假装没事ソ 提交于 2021-02-07 03:54:30
问题 I need to hash a message into a string of 30 chars. What's the best and most secure hash function for this usage? 回答1: Thirty characters (bytes) is 240 bits. If you can't move the goal-post to allow 32 characters, then you will probably end up using SHA-1, which generates 160-bits or 20 bytes. When Base-64 encoded, that will be 28 characters. If you use a hex-encoding, it will be 40 characters, which is nominally out of range. With 32 characters, you could use SHA-256, but Base-64 encoding

Hash function to produce a code of 30 chars?

随声附和 提交于 2021-02-07 03:54:07
问题 I need to hash a message into a string of 30 chars. What's the best and most secure hash function for this usage? 回答1: Thirty characters (bytes) is 240 bits. If you can't move the goal-post to allow 32 characters, then you will probably end up using SHA-1, which generates 160-bits or 20 bytes. When Base-64 encoded, that will be 28 characters. If you use a hex-encoding, it will be 40 characters, which is nominally out of range. With 32 characters, you could use SHA-256, but Base-64 encoding

BCryptHelper.CheckPassword always returns false

与世无争的帅哥 提交于 2019-12-31 04:38:07
问题 I'm implementing password hashing using BCrypt, which should be pretty straight forward to use. However when the password is checked against the hashed password using BCryptHelper.CheckPassword(Password, hashedDBPassword) this always return false. Here is my hasher class: public static class BCryptHasher { public static string EncryptPassword(string password) { var passwordToHash = password; var hashedPassword = BCryptHelper.HashPassword(passwordToHash, BCryptHelper.GenerateSalt(6)); return

PHP: Installing Libsodium to PHP v5.5

天大地大妈咪最大 提交于 2019-12-24 20:16:06
问题 How to correctly install Libsodium with PHP verson 5.5. I'm trying to follow the instruction on https://paragonie.com/book/pecl-libsodium/read/00-intro.md#installing-libsodium Here are the steps I did: Go to http://windows.php.net/downloads/pecl/releases/libsodium/1.0.6/ Download "php_libsodium-1.0.6-5.5-nts-vc11-x64.zip" and extract files. Copy "libsodium.dll" in my directory "C:\Program Files (x86)\PHP\v5.5" where is "php.exe" Copy "php_libsodium.dll" in my directory "C:\Program Files (x86)

Hashing Keys in Java

折月煮酒 提交于 2019-12-21 15:11:13
问题 In java, when I use a String as a key for Hashmap I get a little different result than when I use the string hashcode as a key in the HashMap. Any insight? 回答1: when I use the string hashcode as a key in the HashMap. You mustn't use the hash code itself as the key. Hash codes aren't intended to be unique - it's entirely permitted for two non-equal values to have the same hash code. You should use the string itself as a key. The map will then compare hash codes first (to narrow down the

Hashing Keys in Java

你说的曾经没有我的故事 提交于 2019-12-21 15:11:12
问题 In java, when I use a String as a key for Hashmap I get a little different result than when I use the string hashcode as a key in the HashMap. Any insight? 回答1: when I use the string hashcode as a key in the HashMap. You mustn't use the hash code itself as the key. Hash codes aren't intended to be unique - it's entirely permitted for two non-equal values to have the same hash code. You should use the string itself as a key. The map will then compare hash codes first (to narrow down the

Will similar Strings in HashMap lead to increased chance of collisions?

本小妞迷上赌 提交于 2019-12-20 07:45:20
问题 Consider the following: HashMap<String, Object> hm = new HashMap<>(); final String prefix = "My objects "; int counter = 0; void put(Object value) { hm.put(prefix+(counter++), value); } Given that the key of each entry starts with the same string and only differs by a number appended to it, is this likely to lead to more collisions? I'm trying to decide whether this way of creating unique keys is a good idea from a performance perspective. 回答1: No it will not. And that is not necessarily

djb2 Hash Function

前提是你 提交于 2019-12-18 04:16:19
问题 I am using the djb2 algorithm to generate the hash key for a string which is as follows hash(unsigned char *str) { unsigned long hash = 5381; int c; while (c = *str++) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ return hash; } Now with every loop there is a multiplication with two big numbers, After some time with the 4th of 5th character of the string there is a overflow as the hash value becomes huge What is the correct way to refactor so that the hash value does not overflow and

How to generate desired size (example 8096) long bit hash codes - c# [closed]

女生的网名这么多〃 提交于 2019-12-13 09:14:46
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . There are many hashing methods but I want to compose bit hash with 8096 bits long. Is it possible to achieve this? For example when I enter "House" I should get a string like: "0101010001010101..." (8096 bits)