Skip to content

Content Hash Key

Stephen Oliver edited this page Mar 30, 2017 · 1 revision

Content Hash Keys

All files within Freenet are identified and requested by a key, in a similar way that normal websites are identified by a domain name. You don't really need to know the technical details to use Freenet; tools such as jSite will sort it all out for you.

CHKs are for files that aren't going to change. For example: mp3 files.

They look something like this:

CHK@khy~PN5-P-Ze18SdPfb~eMVCcWv1RTDNaP3ketO3TwQ,-kcC5FBaNN7wZtcHgZGObkxk9221BL5r~wbbVTUhyHc,AAMC--8

These are created by making a hash of the file. This is like a fingerprint of the file: it is generally a lot smaller than the file itself. It should not be possible for two different files to have the same CHK; a CHK uniquely identifies a file (assuming that SHA-256 is not broken!).

This hash is used as an index to the file, in a similar way to the address, or URL, or a standard website. The CHK key is generated automatically, so it won't look as user-friendly as a domain name. For user-friendly keys, have a look at SSK.

Example using TMCI

This example will add a small text file to Freenet using the Content Hash Key to identify it. We will use the basic telnet interface (Console) to Freenet for illustrative purposes but you can use a more featured site creator like jSite.

Note: To enable TMCI if it's not connecting, you need to make sure that the option console.enabled is set to true in Freenet.ini, while the node is shut down. Upon restarting, it should be enabled.

At the command line, type the following to access Freenet's command line interface:

telnet localhost 2323

You should be presented with a list of options. Type the following and then press Enter:

put:this is a test

after a short while (be patient, it could take a minute or two) it will return this:

URI: freenet:CHK@khy~PN5-P-Ze18SdPfb~eMVCcWv1RTDNaP3ketO3TwQ,-kcC5FBaNN7wZtcHgZGObkxk9221BL5r~wbbVTUhyHc,AAMC--8/test.txt

This random-looking string is the Content Hash Key (CHK) of the line of text this is a test, and is telling you the address that other people can use to access this file in Freenet. You can see that it consists of three segments, separated by commas:

khy~PN5-P-Ze18SdPfb~eMVCcWv1RTDNaP3ketO3TwQ is a hash of the file. -kcC5FBaNN7wZtcHgZGObkxk9221BL5r~wbbVTUhyHc is the decryption key that unlocks the file (which is stored encrypted). AAMC--8 contains settings such as the cryptographic algorithms used.

A CHK that includes a filename looks like CHK@<data hash>,<decryption key>,<flags>/[container item].

To exit from the telnet interface, press Ctrl-] and press Enter, then type quit and press Enter.

To verify your file exists in Freenet, open a web browser and go to:

[[http://localhost:8888/CHK@khyPN5-P-Ze18SdPfbeMVCcWv1RTDNaP3ketO3TwQ,-kcC5FBaNN7wZtcHgZGObkxk9221BL5r~wbbVTUhyHc,AAMC--8/test.txt]]

You may get a warning come up at first, but just tell the browser to open it as a plain text page. If all goes well, you should see the text you have just inserted to Freenet.

Example using FProxy

This example will show how to do the same with the HTTP interface at port 8888.

Create a file called test.txt and copy "this is a test" to it without quotes or new lines (don't press return/enter keys). It should be exactly 14 bytes long but you might get 15 or 16 depending on software you used. It's not a big deal so long as the key works when you copy it into the address bar after the ":8888/" part.

Go to http://127.0.0.1:8888/insertfile/ and browse to it to select test.txt to open. For such a small file, it doesn't really matter which browse button you click.

Click on Insert File. Don't bother with a "random, safe key" unless you want to get a different key than this: CHK@khy~PN5-P-Ze18SdPfb~eMVCcWv1RTDNaP3ketO3TwQ,-kcC5FBaNN7wZtcHgZGObkxk9221BL5r~wbbVTUhyHc,AAMC--8/test.txt

If you go to [[http://localhost:8888/CHK@khyPN5-P-Ze18SdPfbeMVCcWv1RTDNaP3ketO3TwQ,-kcC5FBaNN7wZtcHgZGObkxk9221BL5r~wbbVTUhyHc,AAMC--8/test.txt]] then you should see the test file.

Clone this wiki locally
You can’t perform that action at this time.