Source: https://rox.chat/kb/dev/identification/visitor-fields-calculator.html

> This page contains the visitor fields calculator, where you can calculate the checksum (hash) for the fields you specify using one of three algorithms:

# Visitor Fields Calculator

This page contains the [visitor fields](https://rox.chat/kb/dev/identification/visitor-ids.html) calculator, where you can calculate the checksum (hash) for the fields you specify using one of three algorithms:

 * `SHA256`

 * `HMAC-SHA256`

 * `MD5`

!!! Warning "Warning!"
    We strongly **don't** recommend using the `MD5` algorithm. The `HMAC-SHA256` algorithm is preferred.

!!! Note "N.B."
    You can learn more about calculating the checksum, as well as identifying authorized clients [here](https://rox.chat/kb/dev/identification/id-2-0.html).

---

<html>
<head>
  <link rel="stylesheet" href="/kb/stylesheets/calculator.css">
</head>
<body>
  <script src="/kb/js/cryptojs.js"></script>
  <script>
  function hashGet(message, key, hashType) {
    var rawHash;
    var result;
    var input = key + message;

    if (hashType === "sha256") {
      rawHash = CryptoJS.SHA256(input);
      result = rawHash.toString(CryptoJS.enc.Hex);
    }
    else if (hashType === "HMAC-sha256") {
      rawHash = CryptoJS.HmacSHA256(key, message);
      result = rawHash.toString(CryptoJS.enc.Hex);
    }
    else if (hashType === "md5") {
      rawHash = CryptoJS.MD5(input);
      result = rawHash.toString(CryptoJS.enc.Hex);
    }
    return result;
  }
  </script>

  <select id="algorithm">
      <option value="">Choose an algorithm</option>
      <option>sha256</option>
      <option>HMAC-sha256</option>
      <option>md5</option>
  </select><br>

  <div id="calculator">
    <div id="calculatorFields">
      <form name="fields">
        <textarea rows="1" name="key" placeholder="Private key"></textarea><br>
        <textarea rows="7" name="message" placeholder="visitor_fields (string with field values without spaces)"></textarea><br>
        <input type="button" name="calculate" value="Calculate hash"></input>
        <input type="button" name="clipboard" value="Save to clipboard"></input>
        <input type="reset" name="clear" value="Reset"></input>
      </form>
    </div><br>
    <div id="resultBlock"></div>
  </div>
  <script>
    var algorithmSelectBox = document.getElementById("algorithm");
    var algorithmValue;

    function onchange(e) {
      algorithmValue = this.value;
    }

    algorithmSelectBox.addEventListener("change", onchange);
  </script>
  <script>
    var privateKeyValue;
    var keyBox = document.fields.key;

    function onchange(e) {
      var resultBlock = document.getElementById("resultBlock");
      privateKeyValue = e.target.value;
    }

    keyBox.addEventListener("change", onchange);
  </script>
  <script>
    var visitorFieldsValue;
    var messageBox = document.fields.message;

    function onchange(e){
      var resultBLock = document.getElementById("resultBlock");
      visitorFieldsValue = e.target.value;
    }

    messageBox.addEventListener("change", onchange);
  </script>
  <script>
    var calculateBox = document.fields.calculate;

    function onclick(e){
      var resultBlock = document.getElementById("resultBlock");
      var result = hashGet(privateKeyValue, visitorFieldsValue, algorithmValue);
      resultBlock.textContent = result;
    }

    calculateBox.addEventListener("click", onclick);
  </script>
  <script>
    var clipboardBox = document.fields.clipboard;

    function onclick(e){
      navigator.clipboard.writeText(resultBlock.textContent).then(() => {
        alert("The result is saved on the clipboard");
      })
      .catch(err => {
        alert("Error when saving to clipboard", err);
        });
    }

    clipboardBox.addEventListener("click", onclick);
  </script>
  <script>
    var resetBox = document.fields.clear;

    function onclick(e){
      document.getElementById("resultBlock").innerHTML = "";
      privateKeyValue = "";
      visitorFieldsValue = "";
      algorithmValue = "";
    }

    resetBox.addEventListener("click", onclick);
  </script>
</body>
</html>

Instructions for using the calculator:

  1. To select an encryption algorithm, open the **Select Algorithm** drop-down menu and click on the algorithm you want. Your choice will be displayed instead of **Select Algorithm**

  1. In the **Private Key** field, specify (or copy into the field) the private key you are using

  1. In the **visitor_fields** field, specify the visitor fields. Note that visitor fields can be entered as a string containing the visitor field values with no spaces between them (including the contents of the `expires` field, if used).

    Example string with visitor field values:

    ```
    Johnmail@rox.chat12345+104322434671481195621
    ```

  1. After selecting the hashing algorithm and filling in all fields, click **Calculate hash**. The result of hash calculation will be displayed in the field below. To clear the fields, click the **Reset** button. To save the result to the clipboard, click the **Save to clipboard** button
