/react-native-hashcash

React Native C++ turbo module for the new architecture which implements SHA-256 based Hashcash algorithm against brute-force

Primary LanguageC++MIT LicenseMIT

react-native-hashcash

Expo-compatible C++ turbo module for the new architecture which implements SHA-256 based Hashcash algorithm against brute-force

(See react-native-hashcash-old for the version for the old architecture)

Installation

npm i github:tolgaatam/react-native-hashcash#v0.1.0

Usage

Import async function calculateHashcash and execute it with k (difficulty multiplier) and resource identifier

import { calculateHashcash } from 'react-native-hashcash-old'

const result = await calculateHashcash(19, "tolgaatam")

console.log(result) // 1:19:230505:tolgaatam::dwhWzS19EA2rnOes:157149

k must be an integer and the resource identifier must be a string.

With the current situation of smartphone chips, k=19 is the highest comfortable difficult multiplier to choose.

It is advisable to not allow colons in the resource identifier. It could make parsing the resulting hashcash string difficult. URL-encoding the resource identifier would be even safer.

Ceveats

  • Only the most recent Hashcash version 1 is supported.

  • Date format only supports yyMMdd.

  • Salt size is not configurable (16 chars fixed).

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Uses stbrumme's C++ hashing library for calculating SHA256 hashes