# @crpdo/time

> time is the key to all mysteries

[![npm](https://img.shields.io/npm/v/@crpdo/time?style=flat&logo=npm)](https://www.npmjs.com/package/@crpdo/time)
[![pipeline](https://gitlab.com/frenware/core/crpdo/time/badges/master/pipeline.svg)](https://gitlab.com/frenware/core/crpdo/time/-/pipelines)
[![license](https://img.shields.io/npm/l/@crpdo/time)](https://gitlab.com/frenware/core/crpdo/time/-/blob/master/LICENSE)
[![downloads](https://img.shields.io/npm/dw/@crpdo/time)](https://www.npmjs.com/package/@crpdo/time)

[![Gitlab](https://img.shields.io/badge/Gitlab%20-%20?logo=gitlab&color=%23383a40)](https://gitlab.com/frenware/core/crpdo/time)
[![Twitter](https://img.shields.io/badge/@basdwon%20-%20?logo=twitter&color=%23383a40)](https://twitter.com/basdwon)
[![Discord](https://img.shields.io/badge/Basedwon%20-%20?logo=discord&color=%23383a40)](https://discordapp.com/users/basedwon)

This module provides time-related utilities for the parent project, primarily dealing with time-based one-time password (TOTP) generation, verification, and Network Time Protocol (NTP) calculations. `@crpdo/time` is a submodule of the larger `crpdo` project, a comprehensive cryptographic library for Node.js and the browser, which leverages TweetNaCl for various cryptographic functions. 

## Installation

```sh
npm install @crpdo/time
```

## Usage

```js
const Time = require('@crpdo/time')

// Generate a TOTP
const secret = 'my_secret'
const totpGap = 10
const now = Date.now()
const totp = Time.code(secret, totpGap, now)

// Verify a token
const token = 'my_token'
const hashed = true
const range = 1
const result = Time.verify(token, secret, now, hashed, range, totpGap)
```

## Documentation

- [API Reference](/docs/api.md)

## Parent Project

`@crpdo/time` is part of the `crpdo` project. For more information on `crpdo` and its other submodules, please see [the main `crpdo` repository](https://github.com/basedwon/crpdo).

## Tests

In order to run the test suite, simply clone the repository and install its dependencies:

```bash
git clone https://gitlab.com/frenware/core/crpdo/time.git
cd basd
npm install
```

To run the tests:

```bash
npm test
```

## Contributing

Thank you! Please see our [contributing guidelines](/docs/contributing.md) for details.

## Donations

If you find this project useful and want to help support further development, please send us some coin. We greatly appreciate any and all contributions. Thank you!

**Bitcoin (BTC):**
```
1JUb1yNFH6wjGekRUW6Dfgyg4J4h6wKKdF
```

**Monero (XMR):**
```
46uV2fMZT3EWkBrGUgszJCcbqFqEvqrB4bZBJwsbx7yA8e2WBakXzJSUK8aqT4GoqERzbg4oKT2SiPeCgjzVH6VpSQ5y7KQ
```

## License

@crpdo/time is [MIT licensed](https://gitlab.com/frenware/core/crpdo/time/-/blob/master/LICENSE).
