Skip to content
SipHash24 implemented in WebAssembly
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.appveyor.yml
.travis.yml
license.md
loadWasm.ts
mod.ts
readme.md
siphash24.wasm
siphash24.wat
test.ts
test_vectors.json
usage.ts

readme.md

siphash24

Travis AppVeyor


SipHash24 implemented in WebAssembly.

Tailored to Deno

All credit to the original authors Jean-Philippe Aumasson and Daniel J. Bernstein, as well as open-source contributors jedisct1 (Frank Denis), mafintosh and emilbayes for porting the reference implementation to JavaScript and WebAssembly.


Import

import { siphash24 } from "https://denopkg.com/chiefbiiko/siphash24/mod.ts";

Usage

import {
  BYTES,
  siphash24
} from "https://denopkg.com/chiefbiiko/siphash24/mod.ts";

import {
  encode,
  decode
} from "https://denopkg.com/chiefbiiko/std-encoding/mod.ts";

const msg: Uint8Array = encode("msg from a MIB"); // x-byte msg
const key: Uint8Array = encode("sixteen_byte_key"); // 16-byte key
const mac: Uint8Array = new Uint8Array(BYTES); // 8-byte mac

siphash24(msg, key, mac);

console.log(
  "msg: ",
  decode(msg),
  "\nkey: ",
  decode(key),
  "\nmac: ",
  decode(mac, "hex")
);

API

siphash24(msg: Uint8Array, key: Uint8Array, out: Uint8Array): Uint8Array

Mac a variable-length message with a 16-byte key while providing a 8-byte output buffer.


See also

Jean-Philippe Aumasson & Daniel J. Bernstein (2012-09-18). "SipHash: a fast short-input PRF".

SipHash (2-4) implemented in pure Javascript and WebAssembly


License

MIT

You can’t perform that action at this time.