# Hash

**URL:** <https://www.ruby-forum.com/t/hash/114179>\
**Category:** Rails\
**Created:** [September 9, 2007, 6:49am UTC](https://www.ruby-forum.com/t/hash/114179 "2007-09-09T06:49:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f04885/32.png) [@rgreen](https://www.ruby-forum.com/u/rgreen)\
**Post date:** [September 9, 2007, 6:49am UTC](https://www.ruby-forum.com/t/hash/114179/1 "2007-09-09T06:49:27Z")

</div>

What is the purpose of string hash? What would you use it for?  
EXAMPLE: “This is a test.”.hash RETURNS -649841898. WHAT EXACTLY DOES  
THIS REPRESENT? WHAT IS IT GOOD FOR? COMPARISONS?

---

<div class="post-metadata">

**Author:** ![rgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f04885/32.png) [@rgreen](https://www.ruby-forum.com/u/rgreen)\
**Post date:** [September 10, 2007, 9:13am UTC](https://www.ruby-forum.com/t/hash/114179/2 "2007-09-10T09:13:44Z")

</div>

Ron G. wrote:

> What is the purpose of string hash? What would you use it for?  
> EXAMPLE: “This is a test.”.hash RETURNS -649841898. WHAT EXACTLY DOES  
> THIS REPRESENT? WHAT IS IT GOOD FOR? COMPARISONS?

it has to do with Cryptography, it has nothing to do with the Hash  
class, if this is what is confusing you.

> **[Hash function](https://en.wikipedia.org/wiki/Hash_function)**
>
> A hash function is any function that can be used to map data of arbitrary size to fixed-size values, though there are some hash functions that support variable length output. The values returned by a hash function are called hash values, hash codes, digests, or simply hashes. The values are usually used to index a fixed-size table called a hash table. Use of a hash function to index a hash table is called hashing or scatter storage addressing.
> Hash functions and their associated hash tables are...

is a general explination (not just ruby) but i see it fit good enough.  
in terms of usage, well, that’s up to u, i guess.  
hth

–shai
