[identity profile] glukinho.livejournal.com posting in [community profile] useful_faq
Как считается хэш от чего-нибудь, например, файла? Или строки?

Date: 2006-02-09 07:57 pm (UTC)
From: [identity profile] mikser.livejournal.com
Хэш-функции ОЧЕНЬ разными бывают. Можно например выводить в степень каждое число, а ненужные отрезать.

Date: 2006-02-09 07:57 pm (UTC)
From: [identity profile] max-gashkov.livejournal.com
См., например, http://ru.wikipedia.org/wiki/MD5

Date: 2006-02-09 07:59 pm (UTC)
From: [identity profile] mikser.livejournal.com
читай:
http://en.wikipedia.org/wiki/Hash_function
http://en.wikipedia.org/wiki/Cryptographic_hash_function
http://en.wikipedia.org/wiki/Hash_table

Date: 2006-02-09 08:06 pm (UTC)
From: [identity profile] a7sharp9.livejournal.com
Если вопрос в том, как это уже где-нибудь сделано, то для строчек - вот, например, способ, которым пользуется Java (из комментариев в файле String.java):

* s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
* using int arithmetic, where s[i] is the
* ith character of the string, n is the length of
* the string, and ^ indicates exponentiation.