# @bonosoft/sveltekit-base32

> Encode or Decode strings or arrays to and from base32

Latest version **0.0.1** (published 2023-04-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bonosoft/sveltekit-base32
pnpm add @bonosoft/sveltekit-base32
yarn add @bonosoft/sveltekit-base32
bun add @bonosoft/sveltekit-base32
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2023-04-07 |
| First published | 2023-04-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Bonosoft |
| Maintainers | bonosoft |
| Keywords | svelte, sveltekit, base32, encode, decode, encodestring, decodestring, totp, onetime, password |

## Links

- npm: https://www.npmjs.com/package/@bonosoft/sveltekit-base32
- Repository: https://github.com/bonosoft/sveltekit-base32
- Homepage: https://github.com/bonosoft/sveltekit-base32#readme
- Issues: https://github.com/bonosoft/sveltekit-base32/issues
- npm.io page: https://npm.io/package/@bonosoft/sveltekit-base32

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2023-04-07

## README

# Base32 encode or decode for SvelteKit
With this module, you are able use base32 encoding on you Sveltekit site. 

## Install
Use your package manager to install the module:
```shell
npm install @bonosoft/sveltekit-base32
```

## Using base32 in a svelte file in SvelteKit
Now you can start using the Base32 class in your pages.
```ts
<script lang="ts">
  import Base32 from "@bonosoft/sveltekit-base32"
  const base32 = new Base32();
</script>
```

## Encode or EncodeString
With the encode you can use base32 to tranform your data info a string of standard capital letters and digits. The encoding is not an encryption, and can easily be transformed back into the original data.
```ts
    var myEncodedString = base32.encodeString("mySecret");

    const secret = new Uint8Array(10);
    for(let i=0; i<10; i++) {
        secret[i] = Math.floor(Math.random() * 256);
    }
    let base32secret: string = base32.encode(secret);
```

## Decode or DecodeString
The decode functions return the base32 strings back into your original data.
```ts
    var mySecret : string = base32.decodeString("NV4VGZLDOJSXI===");

    console.log( base32.decode("5GJGHSQGJXXNSB5Y") );
```

## TOTP Time based One Time Password secrets
Most TOTP applications requires that your shared secret is a base32 encoded string.<br>
In your browser you are able to make a more secure random secret for your TOTP app.
```ts
    const secret = new Uint8Array(10);
    self.crypto.getRandomValues(secret);

    let totpsecret: string = base32.encode(secret);

```

---
_Source: https://npm.io/package/@bonosoft/sveltekit-base32 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
