25
votes
Laughably tiny random engine
Your question has two parts:
Is the algorithm good?
Is the implementation good?
The first part is not really the purview of code review, because it is not only a mathematical question, it is an ...
17
votes
Accepted
Laughably tiny random engine
Possibility of short cycles
SHA256 is a cryptographically secure hash function, which indeed means the output is very uncorrelated to the input. However, given exactly the same input, it will always ...
13
votes
Accepted
Self-contained SHA-256 implementation in C
Nice implementation. Good attention to shift types.
Use bool. Various members, functions are used only in a boolean fashion. Use ...
11
votes
Accepted
Simple hashing algorithm
I'm not particularly familiar with C, but I have a few observations that may be helpful.
I like the attention to zeroing out your digest before you start. Using uninitialised memory is the sort of ...
10
votes
MD5 implementation in C++11
First impressions
The code seems very clean and tidy. As far as I can tell, you're including exactly the required headers - no more, and no less. There's generally good use of ...
10
votes
Simple hashing algorithm
We really need to start by defining the kind of hash function we've created - this doesn't appear to be a useful cryptographic (one-way) hash function, yet creating strings as output seems to be a ...
8
votes
Custom hash function as Bash script
How would you rate it?
Obscure.
This does not impress me as a supportable codebase.
...
8
votes
Accepted
Custom hash function as Bash script
I see no evidence that this is a cryptographically-strong hash function. You should include a comment that links to a reputable reference for the algorithm you are implementing, so that reviewers can ...
7
votes
Accepted
Basic one way hash to store a password C#
No, it isnt.
First, you only allow ASCII characters in the password. If I were to choose €¥≠≥≤©® as my password, it would probably be equivalent to choosing ...
7
votes
Accepted
A simple Java integer hash set
Bug: array shrinks too much
The logic in shouldContract looks like it is intended to prevent the size from shrinking below ...
6
votes
Accepted
C++ Hashing Passwords - simple algorithm using rand()
Structure
Okay, let's start with the basic overall structure of the function: it's, frankly, not very good. It (unnecessarily) depends on a number of outside variables--from its perspective, ...
6
votes
Accepted
Find duplicate files in Linux
Please be careful with the indentation because it looks like there are different number of spaces for different indentation depths and it looks very weird.
Minor improvements:
Repetition
...
6
votes
Tiny URL creator
I know this isn't really what you're asking for, but I have a couple suggestions about how the code is setup and written.
Coming from languages that use long as a ...
5
votes
Find duplicate files in Linux
The execution time of the program is determined by number of disk reads it has to make. So avoiding unnecessary disk reads by checking first if there is a file with the same size is a good thing. ...
5
votes
Calculate fingerprint for an object
Apart from the improvements suggested by Henrik Hansen and a couple of null checks I changed the list with tuples into SortedDictionary to avoid repetitive ...
5
votes
Updating data file records
#!/usr/bin/python
Consider using #! /usr/bin/env python instead (or python3). Then you can manage import dependencies with ...
5
votes
Accepted
Simple hashing and salting algorithm
I spotted the following problems:
Exception handling When you catch an exception, you just print its stack trace but then keep going as if nothing happened, forcing another exception a few lines down ...
5
votes
Tiny URL creator
While I agree with the other answer that you should not return a special string denoting failure, in Python you should refrain from returning any special return value (though if you do, ...
5
votes
Accepted
Tiny URL creator
If you really want to cut down on the number of characters that you need to guarantee a certain amount of robustness, it would be wise to pick a greater pool of characters to choose from. At the ...
5
votes
Accepted
Securely hash passwords
There are a few things wrong security wise before we even get to the parameters.
private char[] password;
Storing the plain text password in an instance field ...
5
votes
Accepted
Login system using bcrypt and MySQL, to be used for any future projects
Let's start with the SQL and your loginDbMySQL stuff first.
You should probably reconsider the naming of your SQL table columns.
Bare minimum reproducible example ...
5
votes
A simple Java integer hash set
Just an unordered list of things that came to my mind:
You have two rehash() methods doing very different things, an int-...
5
votes
Custom hash function as Bash script
Validate input
The script expects the input is a string with 4 lower-case characters: aaaa to zzzz.
It would be good to enforce this in the script:
...
4
votes
HKDF Implementation in C#
Just a note but I think you have the parameters backwards in GetBytes:
byte[] key = Extract(salt, inputKeyMaterial);
Based on your implementation of:
...
4
votes
Accepted
Hash function in C for sets and associative arrays
... in knowing whether this is a good approach ...
Small improvements
Keep in range
uint_fast32_t may be wider than 32 bits. Values outside the 32-bit range in <...
4
votes
Accepted
F# wrapper to generate SHA256 signature for a file
The use binding is usually better than the using function. The object is disposed when leaving the scope of the ...
4
votes
Irreversibly hash email addresses while preserving format/entropy
Test cases are very limited. You might want to normalise equivalent addresses before hashing; for example, these addresses are all equivalent:
[email protected]
<...
4
votes
Accepted
HashMap Implementation (dictionary) in Python
Your implementation of get is wrong. The code is:
...
4
votes
Accepted
Iter 1: Reusable, robust c++ std::hash<mpz_class> for GMP's big integer type
Answers to your questions
In MurmurHash3_size_t(), I check SIZE_MAX to tell whether I'm on a 32 bit system or a 64 bit system. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
hashcode × 138python × 35
java × 29
c# × 26
performance × 21
c++ × 19
cryptography × 19
python-3.x × 18
algorithm × 16
hash-map × 16
strings × 9
c × 8
security × 8
file × 7
php × 5
file-system × 5
programming-challenge × 4
c++11 × 4
authentication × 4
beginner × 3
.net × 3
python-2.x × 3
unit-testing × 3
random × 3
swift × 3