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

kissmyhash

v2.0.3

Published

Hashes as long and strong as you need. It defaults to 1024 bytes, but you can set higher or lower. It based on PRNG and xor operations, and its code is so short and clean with nothing obscure that it is easy to undersand how it works.

Downloads

4

Readme

kissmyhash

Hashes as long and strong as you need.

It defaults to 1024 bytes, but you can set higher or lower.

v2

  • Now it uses a different default serializer
  • A bug that potentially caused hash collisions with unicode characters has been fixed

Because of that, v2 hashes are not compatible with v1 hashes

Why?

You might have some scenario where you want to use longer thus stronger hashes, maybe so they can age better.

Examples

const kissmyhash = require('kissmyhash')

// hash a string using defaults (1024 bytes 8192 bits)
kissmyhash('hello word')
// -> 'ljnFw3n-Fquht3Q8e5trpjGlQLOGHtV-pgdWyNX1W9HgAZzgSSzZbcFpiN73T9XKx8HIrM5cAmqVkO8vaUt4G3XuPaDieLE_VNJTNedoiT7WkFwAW2gUjQ4GiTk4cWMvDypqtwj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b9k__daTHv4YEGSej6FPGusZY7MeqXnj8jpk1prqlPOlkx7it4I4PJsRmiY8ZHcCUUNvqFqsH5tokP9mK5MpyXtZ6Si6RgnXc3DnM-CKQXqzv9IpxawulMTndEkT7tgpdMZaE7DGGWpCo3x5wd-pAfqouA'

// hash a string with a smaller byte length 64 bytes (512 bites) like SHA512
kissmyhash('hello word', { length: 64 } )
// -> 'SN4PMkkpJfRzCzxATQlikXpjzWGxdxMITKX5G6cnd3AxiXznHSLc9sIVRFw1aHKSmLkeLdL09cDzVVUPTq9U3w'

// hash an object with a medium size byte length
kissmyhash({message: 'hello word'})
// -> 'Q5SVUp4Ov8VftIj7p8n5UCFJreRhVNttQsfMmQ5y6q1HPuWlsqC4ogIPlv-1H0dyaxJ7V5m622xcI0P8pmZ95aAfLFXCdPD4gmvtPnnMvWQ2L0WO-xOR0TKSSkmfq9anfkTv72yBbgppgxQbNLvNHXloXEP_YzBPwoKGKSm5qXjZ2CK52qBOi1lTfW4rbicstRkjUTZwKyNgfSLZ1RB3wcuANR4eHyZ5DTnmGMgUjShyhOsTShyEv1WmH42FpLck1BuC49eaqiQ8VYKwWtB8CbAsvnXI0x7laDWEX8axULNqPlYRIDuqYve3uwWjJAgw6NA0XXQ7uxrvBAzQBzu3s_7cfoOn315ENJtd3_9fGYQrLY5P-TCiNWbuBdENR1ZuITfYmpUMB6JdFNy3emcc4W7RBVL1X7V9AsrDSwFnXhM5HP9Dw1AfD-Rmf5ZAgsSJ0VDFHiU6QN-zQjkjQaGhlD9GZjMs0RJFRZAzH09xni4sBbpqfte0Jy72jtzfR6ujfidrD3tzUXsrYAhBoB6Cz2g5ftJiNKFutg-en9AE_XbeJ0-7BJqCIQ2aPPpg_k1c3udR7rqQ8UME_1lehzUWl1bujB8QBMqCsgupbRLEFN4UU19zK_AQc91WHfoTIhpI41G_m9wGIeq7zUEANITSCf6AaQj0I2Unf-vIy6bzjaXqb5798ST3lxc9Z0vN5u_i5p8AZY17gmH8OtAkcfvKCnMRMSQrjgHflwubDTe0SANRb3jNl5tiyNvNVeO0PS0b7TJejrvrc3huv_2v_-hqqNUU-dCDEH3O80JUUVqOoGZzRTrrhcQJ66aXXrpwSnX4avxbXpRRX_FrcZIDv1qEZQvXnJUj4VdRFWIscj5gZhGj5l3VOT0pkoAZL6xuHMpLbGDHoNGiB31eiCIt_PwuPvDWpi7N9Z5U-1stmxOmr3YYZCEwlOx2uhGoBMYrrP4k0aDcIEFC_j-I496HdVrXDvRmPTx6U6LBF9xJBP9z3NaW-u8iXTK97Qtrj9AEnqiUzXrNUsFQf7wrk0XcsqkNQ5Khe9OBerUzTjIC7ax4tPFTSGCuel_8qcnJiVGWkvUIAUNEeW3ejh_s-5kLnHMwimtcrezRbZ4GYM4adg-ySjuDTbK_eohGh9BiRwDetOb0_JPCmI4HOtHXOxgZuIlefEvtfnMLr4VpzytrIUV5WXcgLfp552mUzQxryN0iybkZKOX7NG0665JLcHTpmXtPmwysw7fQQALwExoQBuC52V27dmq3vesl0ciUG_bG31EnzK7XPEvJrM7mAyXM2CXDvoGHXrngDqULFxID0_O2iYLy4gfIekk_BSk47bfOl7nPhd3S7ckMq_37t28AiHs7VQ'

// hash using a different PRNG
const alea = require('seedrandom/lib/alea')
kissmyhash({message: 'hello word'}, { prng: alea })
// -> 'Bpin6UBCnShRetOsQ4h4kZ37ABmXk_qYiE1IZgRKntAGsWru62EWU7XnJZDYCUumBHiUVeqSrQ6tcQPO4l95IHvRw5QJzVLmVkHjjsJs3IMcdPZ07cK6aNTeHho-1V78K7fHuujouaRHqLwj3sJ1QpCoVdVPWsZDQDacWi3ygIYeYTk58gnxLs5s4r_32TzAgOnK07CqzkXK7t0xRUlfJkGnPKRPoSGsUE7IHSR6z3BOsE_GUymXsLr1KsxWsthSNQfhY1HkIzbqE6VUD66lg13VdxdrJNjeKcOQUx2_3ejC5BfpniNnXyJDSi2pwwxClmneRfZ2iWTiyewnCJZ1f9eSjgnfizuC72KuO3fELPG8xFAx3L_aL1x1tO_PFn5BO3cqMaYhmWAGHjxraA8mOc1vU_P3sZgTVLjyIw3W9TuTHVsL7N-oPNXzRwU7obCswC1nsNoEy1tqHBvJIzSYqpMvseDhJ4FE-azLNFl68h2qz3L8sOXp-kH7drJPufUwz61vRp8dwYxQvEdW3W1KecjAP0_Gy-Ejaoa1ryYu9O-KKhGOPamoHBcRrl463ff3RgOOXB34uJwGSLpPIbjv0c_SeyeImWLt8TUf7hsajzwsYW1bVpGm0i9FM7uEStPiQV-WqntduN1FWH2MdsIX990qGxJAlBZNG1Ei-9NVdWYFYGt3Vs-aySN-U3IbllSGRSITR7_IkMc4dL-XGQj3NLlc5DLu4-E4PNKkGsNAPXa4qPT3hhQA6u0cOwmWEa_6VF5x0j7PQfkw_EnC2MJfPVDXfEODXjNDhtMX8pVxfI_deRN77v0N2Xs1-qKvQGHftip4TTzEELPEE-owDstPeO5PIGuh5bIlWRSxKYyxG4O2sLnHjvcmlC2yB8vODDgR9usMUUI2isPO7GZuHUKmizVMGqrIQOvh8_NB3Z74n6Z29Zs7NgS2sAm-c3Na1U_g0M7gFz3zr_MHnj6U03oWuDh0vyHR0-RHPEvkT4e_kIQKrIKW0VqsiN4YI7j18PU20ldqSkXh3gnq7goYmCBUoKYeISV0JoZaYhpoa1YTmKOFrUwlQK8VzW0dRWkHGO9Z0Q0ah8N_jtsowF97BNEailOVj-N8utjxQU-IhmPtWLsg_g-0g4tOBYYUeEh1bFWvID2LENx7BDlxTOCYelGK2gPNg1qQj1fPKm4zHUPEhqji4O4RXjCv-ab2-5efukgA_Z_AMQOnFq227XCxIfKnoSU1SVgkDiCEwymEewEZlBMAe7t2_BiNRgkniD0uYEhf0C3Kc8_fchIX_Sre79-AyOpD24XNQtwFCzy-OTSQfAAG-F5cXv4CFKneMFVchDeojtzhsOxbTEYYbc3U0stZKA'

// hash using a custom serializer
const serializer = (ob) => JSON.stringify(ob).split('').map(c => c.charCodeAt(0))
kissmyhash({message: 'hello word'}, { serializer })
// -> 'R_OUoCxVJMkT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EoyTjCfxBY652d-IUkn8yQw58I-NPqT9TU6xPJjF-44_Yj1jBlggJoHZEC_x7-Xz5SS7UebBse9YzP2YqUXPQgj8ascemAY3jTZsBpk_SK1dUqi6aKT-mf7XAdI-X9lH_6ffJhLE1C4uEMZv3AZRPj4utAXplzo7pPD92tyzqrn8bedJ5NF8bn_HfSegjT6ftjfwENi7Anaw-cEb2bUnPLGYnE5DWo_yZik6I-msukVe4RdCKUN7e_5fV5YO7SKJm4PUemnVO8o_Cv6m6dZ5E2FO2YwzPew'

Reference

kissmyhash(data, [options])

data

it must be anything serializable by the serializer.

options

it is an object with three optional fields:

  • length: The amount of bytes the hash will have. It defaults to 1024
  • prng: You can set a different pseudorandom number generator. It should be a function that accepts a (numeric) seed, and it should return an object with the method int32 that returns the pseudo random numbers. It defaults to seedrandom
  • serializer: You can set a different serializer. It should be a function that returns an array of numbers, or Uint8Array. It defaults to bencode.encode

Warnings about hashing objects with default serializer bencode.encode.

Circular references

The serializer does not support circular references. If you try to hash an object with circular references it will throw Uncaught RangeError: Maximum call stack size exceeded

Booleans and floats

The objects are being serialized to bytes by bencode, and it has no support for booleans and floats, so that true becomes 1, false becomes 0, and floats are truncated.

That can lead to hash collisions.

If you plan to hash objects with floats and booleans you might preffer to hash the JSON serialization of the object instead, or to use a different serializer.

Warnings about customizations.

If you intend to share your hashes with other people, in signatures for instance, you need to make them know what length, prng and serializer are you using, so they can check your hashes.