Click here to Skip to main content
15,886,724 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
PIEBALDconsult24-Nov-21 1:53
mvePIEBALDconsult24-Nov-21 1:53 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
Eddy Vluggen26-Nov-21 10:26
professionalEddy Vluggen26-Nov-21 10:26 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
Philippe Verdy26-Nov-21 3:32
Philippe Verdy26-Nov-21 3:32 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
harold aptroot26-Nov-21 5:08
harold aptroot26-Nov-21 5:08 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
PIEBALDconsult26-Nov-21 10:00
mvePIEBALDconsult26-Nov-21 10:00 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
harold aptroot26-Nov-21 10:27
harold aptroot26-Nov-21 10:27 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
brian012528-Nov-21 16:53
brian012528-Nov-21 16:53 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
Philippe Verdy8-Sep-22 20:14
Philippe Verdy8-Sep-22 20:14 
Just consider if your table size is a multiple of 5...

The hash value itself, even if it's a power of 2, is not sufficient: the multiplier msut be a coprime of the integer size (a power of 2, so the multiplier must not be even) cannot AND of ANY hash table size (which can be quite arbitrary integer, not necessarily a power of 2).

That's why using primes is always better. And why usually, the factor used in Fast Knuth Algorithm is a prime near the value of sqrt(2^(N-1)), for a generated hash value in [0, 2^N), i.e. the largest prime near below 2^(N/2); for a 32-bit hash value this means using the prime factor just below 65536, like 65521 or 65537 (but the 1st is better as the number of bits 1 or 0 are more equally balanced); but if your hash value will index strings of 1-byte characters or variable-length array of bytes (which are 4 times smaller in bitsize than the hash value), you'll use a factor near 2^4, rounded up to take into account for short strings, so you'll use the factor 17 (which contains 2 bits set to 1 and 2 bits set to 0: it is balanced and has good randomization properties): using a factor of 17 is also very fast to compute even if you don't have hardware multiplier in the instruction set of your ALU, or even if you don't have hardware shifts (it can be computed noly with 5 additions in that case, and a single pair of CPU registers; but this use is now extremely rare except in very cheap 8-bit controlers).
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
harold aptroot9-Sep-22 1:01
harold aptroot9-Sep-22 1:01 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
Philippe Verdy9-Sep-22 1:31
Philippe Verdy9-Sep-22 1:31 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
brian012528-Nov-21 16:54
brian012528-Nov-21 16:54 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
Philippe Verdy8-Sep-22 20:37
Philippe Verdy8-Sep-22 20:37 
GeneralRe: Does anyone recognized this "decryption" algorithm? Pin
brian012528-Nov-21 16:31
brian012528-Nov-21 16:31 
GeneralRA8875 has ridiculous registers Pin
honey the codewitch16-Nov-21 1:31
mvahoney the codewitch16-Nov-21 1:31 
GeneralRe: RA8875 has ridiculous registers Pin
Greg Utas16-Nov-21 1:39
professionalGreg Utas16-Nov-21 1:39 
GeneralRe: RA8875 has ridiculous registers Pin
honey the codewitch16-Nov-21 1:42
mvahoney the codewitch16-Nov-21 1:42 
GeneralRe: RA8875 has ridiculous registers Pin
Jörgen Andersson23-Nov-21 3:00
professionalJörgen Andersson23-Nov-21 3:00 
GeneralRe: RA8875 has ridiculous registers Pin
den2k8816-Nov-21 1:45
professionalden2k8816-Nov-21 1:45 
GeneralRe: RA8875 has ridiculous registers Pin
honey the codewitch16-Nov-21 4:13
mvahoney the codewitch16-Nov-21 4:13 
GeneralRe: RA8875 has ridiculous registers Pin
PIEBALDconsult16-Nov-21 4:10
mvePIEBALDconsult16-Nov-21 4:10 
GeneralRe: RA8875 has ridiculous registers Pin
honey the codewitch16-Nov-21 4:13
mvahoney the codewitch16-Nov-21 4:13 
GeneralRe: RA8875 has ridiculous registers Pin
Fueled By Decaff16-Nov-21 4:18
Fueled By Decaff16-Nov-21 4:18 
GeneralRe: RA8875 has ridiculous registers Pin
honey the codewitch16-Nov-21 4:19
mvahoney the codewitch16-Nov-21 4:19 
GeneralRe: RA8875 has ridiculous registers Pin
Fueled By Decaff16-Nov-21 4:48
Fueled By Decaff16-Nov-21 4:48 
GeneralRe: RA8875 has ridiculous registers Pin
honey the codewitch16-Nov-21 5:07
mvahoney the codewitch16-Nov-21 5:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.