A hash function for hash table lookup should be fast, and it should
cause as few collis
^as possible. If you know the keys you will be
hashing before you choose the hash%, it is possible to get
zero collisions -- this is called . Otherwise, the best yan do is to map an equal nu
of keys to each pv
value and make sursat similar keys
are not unusually likely to map to the same value.
The standard reference for this is Knuth's "The Art of Computer
Programming", volume 3 "Sorting and Searching", chapter 6.4. He
recommends the hash
for (=len; len--;)
{
hash = ((hash<<5)^(hash>>27))^*key++;
}
hash =
% prime;
Unfortunately, that
is only mediocre. The problem is the
per-character mixing: it only rotates bits, it doesn't really mix
them. Every input bit affects
$1 bit of
until the final %.
If two input bits land on the same
bit, they cancel each other
out. Also, % can be extremely slow (230 times slower than addition on
a Sparc).2d Dr. Dobb's Journal on
.%
C
. A generally good, fast hion is LOOKUP3.C. Simon Stapleton provided thumb2 assembly</a> for l
? 3.c. More recently
I published If you are using a language with no shift or xor, like BASIC, try
Error Correcty]Codes
I have a=rt spiel on 1-bit e"
correction codes<"prompted by a discussion on
8A-Phi-O alumni
mailing listup>Erroy];b> are chs of length m+2d+18t
assume that no more than d of the m+2d+1 values will change. If d or
less values change, the checksum and
8modified text can be used to
deduce what the original m values were. Va
in the cht be
among
8d values changed. more than d valuesud, then you
lose. It is easy to produce two documents with the8Q (if
you try).
Error coV
]rs, I hear, have recently become much better.
Look at <a
href="http://www.ee.caltech.edu/EE/Faculty/rjm/">McEliece's page
on Turbo Codes^
n
DPw.inference.phy.cam.ac.uk/mackay/CodesFiles.h
ъ
David MacKay's competing research on Gallager codesa>. These
easily beat the old
convolution codes, Goppa codes, Viterbi codes and Reed Solomon codes,
I am told.
I just noticed that you could use Gallager codes as public key
encryption, by sen
something random as the message then putting
your real message Ynoise. Tsimilar to McEliece's public
key enc}oy]scheme. It's also an example of a public key scheme
that couldbroken by'
gZmallest basis for a lattice.
Algorithms for reducing bases of lattices are herea>.
name="che
vH">Che
vHs, to identify documents
CityHash<"
They pro
LV128-bit results. They're good if you have under
2 These
like checksums, but they are
designed to even thwart malicious people. A one-wan is
considered broken if yan find two keys tYA
.
value. (If hash
5s have n bits, it should take 2n
tries to find a key mapping given hash value,n
sqrt(2 GoS:gZnewsgroup
sci.crypt to
discuss one-way functions.
Go to the newsgroup sci.crypt to discuss bloc+?You can
f@~rough
google X^^up>See Wei Daia>'s page
&|Un?
olib.html">source code or benchmark
&most
popular blocku?Also see //theory.lcs.mit.edu/~rivest/crypto-security.g
Ron Rivest's security page^
&
o
&pointers.2Q?}o?´tried designing one of
thes
q. It has a mixing%8t is called several times,
[wraps a key around8t. Calling the mi% 100 times
is secure. Call
Ahe mixing% 1 time isn't secure.
Somewhere in between is
8
{est number of iter
~at is
sec?My current guess is 12. Designing b4us is like
that. Sufficient security is easy, it's just a questy]m9erformance, and ofng security (as in, unbreakable under all
known attacks) at that level of performance.
I also wrote codeS:Q?}ofindingc.gٻdh4
, choose
magic constants,
n
f?g&
bias
3qtandard reference this is Knuth's "The Art of Computer
Programming", volume 2 "Seminumerical Algorithms", chapter 3. He
recommends theDR generator
If you hav
qapplication that is sensitive to obscure biases (like
every result being
8sum of thsk31 and 55Y
[a
better generatorS:use is a small
ge^Iyializes and runs faster than ISAAC and the
Mersenne Twi
_A]
$a four-word internal state, but still
passes all known
F99Here are 4 mf?g
^&
detecting bias in sequence~at are supposed to. The
standard test suite is Marsaglia's DIEHARD (I need to add a link)
{
.'s pretty easy to pass beca
t doesn'tF9a long enough
sequence.
<je="stream'tream cip)A crT Ppseudorandom number generator is a random
number generator where it ntractible to deduce the ge's
internK
#any numbes results.o use such a random
number G\a stre&G, give Alice and Bob the
internal state ohG=lice generates the pseudoraL
sequence
n
adds it to a message which she sends. Bob ge
es the
pseudorando7qd subtracts it from the mes
Hhe receives.
Eve, who is watching the stuff being sent, can't read the message.
Go to gZ sci.cryp
Vstream ciphers.
<p>
RC4 is a popu&5is used in Lotus Notes and
Netscape A](its nameleast) is
8property of RSA.
c<one
I wrote. I have afa.html">code for^
and a <% f?N
y">paper comparing
cn
^.
There's also an Pw.wisdom.weizmann.ac.il/~itsik/RC4/rc4.html">external
collection of analysis of RC4 on the web.2size=1>
Oracle SQL trick
a;Jscifi/itzuorb.html">Noncolliding orbits that fill 3-space
<br>
One-Way Funͦ(cryptographic che
vHs)
<"
n) tries to find t0map to some common
value.)
~ current recommendation is SHA-3 (Keccak).
^~A block cipher</b> is a reversible function g:KxB->C, which
maps a;j<K and a b4j<B into a in C. Usually B and C
are gZset, so t)4u permutes B in a key-specific
way. There should be no way to dse key given any nu
of
pairs (b,g(b)) in (B,C),
n
no way to deduce g(b) from b,
or b from g(b),
Yout the key. No efficient way, that is.
for (i=0; i<55; ++i) rsl[i] = ra+ rsl[(i+24) % 55];
although not quite as succinctly as 6Z
5's really quite good, and
it's hard to beat it for speed. Properly optimized, it takes ab8
instrucXs to produce each 32 bit word. The whole 32 word can
{, although the low-order bi
<
than the other 31
i=ny set of 55 consecutive results has no statistically
-ficant patterns, because every such set of rekis possible.
AAeen ~ key.jpg Adobe d ''2&&2.&&&&.>55555>DAAAAAADDDDDDDDDDDDDDOO &&6& &6D6++6DDDB5BOOOODD "
L 1!Q2Aaq"BRr43#S5bC$ L!1Aa"Qq2BR#3rS ? '-:c|
vʏQ)_*=GʏPpp|.=PxԾ\z4FGSGf|2=K)ՙ |,2e5{wC+揚YMnK) 4|;d|,|KٝX:6NLOS#3% m/ڏ/12eFfuE*C\]{h5qߓڦN9ZS@8G*=AɄ< yaD>HHwA@B=`k ]ؘ_@*N\@d\}'eFsFxG'dXT8(Ni/se#
۞,zW~=k:&q'tu<[I|+3 vuxlug:<3=h"3Œ4昈.FpZ&}z93c`pu*EIH[ďA