npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

keccakkotlin

v0.2.0

Published

SHA-3 Hash Functions in Kotlin

Downloads

260

Readme

KeccakKotlin (NPM build)

Parent Source: KeccakKotlin

Generated from parent KMM library using ./gradlew bundleNPM

Installation

npm install keccakkotlin

Documentation

Visit keccak.hombre.asia. All common methods and classes are available in JS.

Usage sample

const { KeccakHash, KeccakByteStream, KeccakParameter } = require("keccakkotlin").asia.hombre.keccak;

function test224() {
    console.log("Testing SHA3-224...");
    let hash = KeccakHash.Companion.generate(KeccakParameter.SHA3_224, Buffer.from(""))
    let answer = "6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7"

    console.assert(Buffer.from(hash).toString('hex') === answer, "Incorrect SHA3-224 Hash!");
}

function test256() {
    console.log("Testing SHA3-256...");
    let hash = KeccakHash.Companion.generate(KeccakParameter.SHA3_256, Buffer.from(""))
    let answer = "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a"

    console.assert(Buffer.from(hash).toString('hex') === answer, "Incorrect SHA3-256 Hash!");
}

function test384() {
    console.log("Testing SHA3-384...");
    let hash = KeccakHash.Companion.generate(KeccakParameter.SHA3_384, Buffer.from(""))
    let answer = "0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004"

    console.assert(Buffer.from(hash).toString('hex') === answer, "Incorrect SHA3-384 Hash!");
}

function test512() {
    console.log("Testing SHA3-512...");
    let hash = KeccakHash.Companion.generate(KeccakParameter.SHA3_512, Buffer.from(""))
    let answer = "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26"

    console.assert(Buffer.from(hash).toString('hex') === answer, "Incorrect SHA3-512 Hash!");
}

function testrawshake128() {
    console.log("Testing RawSHAKE128...");
    let hash = KeccakHash.Companion.generate(KeccakParameter.RAWSHAKE_128, Buffer.from(""))
    let answer = "fa019a3b17630df6014853b5470773f1"

    console.assert(Buffer.from(hash).toString('hex') === answer, "Incorrect RawSHAKE128 Hash!");
}

function testrawshake256() {
    console.log("Testing RawSHAKE256...");
    let hash = KeccakHash.Companion.generate(KeccakParameter.RAWSHAKE_256, Buffer.from(""))
    let answer = "3a1108d4a90a31b85a10bdce77f4bfbdcc5b1d70dd405686f8bbde834aa1a410"

    console.assert(Buffer.from(hash).toString('hex') === answer, "Incorrect RawSHAKE256 Hash!");
}

function testshake128() {
    console.log("Testing SHAKE128...");
    let hash = KeccakHash.Companion.generate(KeccakParameter.SHAKE_128, Buffer.from(""))
    let answer = "7f9c2ba4e88f827d616045507605853e"

    console.assert(Buffer.from(hash).toString('hex') === answer, "Incorrect SHAKE128 Hash!");
}

function testshake256() {
    console.log("Testing SHAKE256...");
    let hash = KeccakHash.Companion.generate(KeccakParameter.SHAKE_256, Buffer.from(""))
    let answer = "46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762f"

    console.assert(Buffer.from(hash).toString('hex') === answer, "Incorrect SHAKE256 Hash!");
}

test224();
test256();
test384();
test512();
testrawshake128();
testrawshake256();
testshake128();
testshake256();

console.log("Success!")

//Stream
/*
let stream = new KeccakByteStream(KeccakParameter.SHAKE_128);

stream.absorb(Buffer.from(""));

let accumulator = new Int8Array(512);

for(let i = 0; i < 512; i++) {
    let byte = stream.next()
    accumulator[i] = byte;
}

console.log(Buffer.from(accumulator).toString('hex'));
*/

License

Copyright 2024 Ron Lauren Hombre

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

       https://www.apache.org/licenses/LICENSE-2.0
       
       and included as LICENSE.txt in this Project.

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.