import { createServer } from "http";
import crypto from "crypto";
const PORT = 8001;
// this is from the web-socket specification and not something that is generated
const WEBSOCKET_MAGIC_STRING_KEY = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
function DJB2Hash(key: string) {
let hash = 5381; // magic start djb2 number
for (let i = 0; i < key.length; i++) {
hash = (hash << 5) + hash + key.charCodeAt(i);
// using (hash << 5 + hash) instead of hash * 33 because '<<' is operation is faster than '*' on computer cpu
hash = hash & hash;
}