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

@iota/checksum

v1.0.0-beta.30

Published

Add, remove and validate checksums

Downloads

48,698

Readme

@iota/checksum

Add, remove and validate checksums.

Installation

Install using npm:

npm install @iota/checksum

or using yarn:

yarn add @iota/checksum

API Reference

checksum.addChecksum(input, [checksumLength], [isAddress])

Summary: Generates a checksum and appends it to the given trytes.
Throws:

  • errors.INVALID_ADDRESS : Make sure that the given address is 90 trytes long.
  • errors.INVALID_TRYTES : Make sure that the input argument contains only trytes
  • errors.INVALID_CHECKSUM_LENGTH : Make sure that the checksumLength argument is a number greater than or equal to 3. If the isAddress argument is set to true, make sure that the checksumLength argument is 9.

| Param | Type | Default | Description | | --- | --- | --- | --- | | input | string | | 81 trytes to which to append the checksum | | [checksumLength] | number | 9 | Length of the checksum to generate | | [isAddress] | boolean | true | Whether the input is an address |

This method takes 81 trytes, which could be an address or a seed, generates the checksum and appends it to the trytes.

To generate a checksum that is less than 9 trytes long, make sure to set the isAddress argument to false.

Related methods

To generate an address, use the getNewAddress() method.

Returns: string - The original trytes with an appended checksum.
Example

let addressWithChecksum = Checksum.addChecksum('ADDRESS...');

checksum.removeChecksum(input)

Summary: Removes the checksum from the given address.
Throws:

  • errors.INVALID_ADDRESS : Make sure that the given address is 90 trytes long.

| Param | Type | Description | | --- | --- | --- | | input | string | Address from which to remove the checksum |

This method takes an address of 90 trytes, and removes the last 9 trytes to return the address without a checksum.

Related methods

To generate an address, use the getNewAddress() method. To add a checksum to an address, use the addChecksum() method.

Returns: string - The original address without the appended checksum.
Example

let addressWithoutChecksum = Checksum.removeChecksum('ADDRESS...');

checksum.isValidChecksum(addressWithChecksum)

Summary: Validates the checksum of an address.
Throws:

  • errors.INVALID_ADDRESS : Make sure that the given address is 90 trytes long.

| Param | Type | Description | | --- | --- | --- | | addressWithChecksum | string | Address with a checksum |

This method takes an address of 90 trytes, and checks if the checksum is valid.

Related methods

To generate an address, use the getNewAddress() method. To add a checksum to an address, use the addChecksum() method.

Returns: boolean - Whether the checksum is valid.
Example

let valid = Checksum.isValidChecksum('ADDRESS...');