File: ReadMe.md

Recommend this page to a friend!
  Classes of Martin Latter  >  JavaScript Cryptographic Chat  >  ReadMe.md  >  Download  
File: ReadMe.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: JavaScript Cryptographic Chat
Chat system that exchanges encrypted messages
Author: By
Last change: update ReadMe.md
Date: 3 months ago
Size: 3,711 bytes


Class file image Download


Lightweight end-to-end encrypted chatbox using JavaScript, PHP, and MySQL, with an emphasis on speed and minimalism.

[1]: https://tinram.github.io/images/cchat.png ![cchat][1]


Uses a previously agreed password with the recipient, avoiding any initial key exchange across a network.


  • Lightweight (45kB).
  • All data encrypted by the browser's JavaScript.
  • POST AJAX used (GET AJAX data would be recorded in server logs).
  • Coded to PHP 5.3 and using legacy JavaScript event handlers for maximum server-client compatibility.


  • SHA-256-hashed key.
  • Blowfish cipher in CBC-mode (base64 display overlays binary-encrypted data).
  • Messages stored encrypted in the database.

The Blowfish block cipher is simple, strong, and fast. Its speed is ideal for JavaScript implementation.


  1. Clone the repository / extract the file archive into a suitable directory in the server's web directory.
  2. On *nix servers, set appropriate file ownership on this directory.
  3. Edit the configuration section details in /install.php (line 18 onwards): username, passwords, database, host etc.
  4. Edit the constants in /classes/cchat.class.php (line 18 onwards) to be identical to those in /install.php
  5. Run /install.php through your server (which, if you have root MySQL access, should mean set-up is complete ...
  6. View CChat's /index.php in a browser, which if install.php ran correctly, should display without connection errors to the server.
  7. Alter the timezone if required: /index.php (line 5): date_default_timezone_set('Europe/London')



  1. message display
  2. your name
  3. your password (use a strong password, previously agreed, to share messages with a recipient)
  4. your message

The decrypt button will decrypt existing encrypted messages in field 1, if the correct password is present in field 2.

Enter your name in field 2, password in field 3, and a message in field 4, then click the chat button.

A page refresh (encrypted messages displayed) or the wrong password will result in gibberish displayed in field 1.

Default Timings

The AJAX polling is 6 seconds between server checks for new messages (change the iCheckFreq variable (in microseconds) /js/cchat.js (line 17)).

The last hour's messages are displayed in field 1 (change the MESSAGE_BUFFER constant /classes/cchat.class.php (line 24)).

Character Set Limitation

Unicode character encoding is unfortunately not possible with the present JavaScript Blowfish cipher encryption (the reason the database remains as latin1 encoding).

Known Bugs

  1. Intermittent duplicate message bug (refresh page and it disappears): /js/cchat.js (line 294).
  2. Some intermittent line break character removal when using Linux and Windows browser clients together.


  • Nils Reimers for the Blowfish cipher in JavaScript.
  • Angel Marin and Paul Johnston for the SHA-256 hash function in JavaScript.
  • Matthew of JS Classes for testing / revision suggestions.
  • Karl, who asked me to create a 'shoutbox' in 2010.


  • To God (I narrowly escaped death in 1992).
  • To Sofia.


CChat is released under the GPL v.3.



Won a JS Classes Innovation Award (August 2016).