Skip to main content
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 ...
indi's user avatar
  • 16.5k
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 ...
G. Sliepen's user avatar
  • 69.3k
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 ...
chux's user avatar
  • 36.4k
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 ...
Josiah's user avatar
  • 6,106
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 ...
Toby Speight's user avatar
  • 88.4k
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 ...
Toby Speight's user avatar
  • 88.4k
8 votes

Custom hash function as Bash script

How would you rate it? Obscure. This does not impress me as a supportable codebase. ...
J_H's user avatar
  • 42.3k
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 ...
Toby Speight's user avatar
  • 88.4k
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 ...
Roland Illig's user avatar
  • 21.9k
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 ...
user555045's user avatar
  • 12.4k
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, ...
Jerry Coffin's user avatar
  • 34.1k
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 ...
Caridorc's user avatar
  • 28.1k
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 ...
Carcigenicate's user avatar
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. ...
miracle173's user avatar
  • 1,388
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 ...
t3chb0t's user avatar
  • 44.7k
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 ...
J_H's user avatar
  • 42.3k
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 ...
mat's user avatar
  • 206
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, ...
Graipher's user avatar
  • 41.7k
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 ...
AlexV's user avatar
  • 7,363
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 ...
TorbenPutkonen's user avatar
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 ...
Thomas Ward's user avatar
  • 2,548
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-...
Ralf Kleberhoff's user avatar
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: ...
janos's user avatar
  • 113k
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: ...
Anonymous's user avatar
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 <...
chux's user avatar
  • 36.4k
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 ...
TheQuickBrownFox's user avatar
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] <...
Toby Speight's user avatar
  • 88.4k
4 votes
Accepted

HashMap Implementation (dictionary) in Python

Your implementation of get is wrong. The code is: ...
Jack M's user avatar
  • 404
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. ...
G. Sliepen's user avatar
  • 69.3k

Only top scored, non community-wiki answers of a minimum length are eligible