Giter Site home page Giter Site logo

jeremybarbet / react-native-jsi-base-coder Goto Github PK

View Code? Open in Web Editor NEW
82.0 4.0 1.0 435 KB

Base64/32/16 encoding/decoding for React Native written in C/C++ and JSI.

License: MIT License

JavaScript 9.66% CMake 4.39% C++ 22.89% Java 12.30% TypeScript 34.15% Swift 0.19% Ruby 5.38% C 0.33% Objective-C 7.47% Objective-C++ 3.23%
android ios react-native jsi base32 base64 cpp crockford decode encode

react-native-jsi-base-coder's Introduction

react-native-jsi-base-coder

Base64/32/16 encoding/decoding for React Native written in C/C++ and JSI.

Installation

React Native

yarn add react-native-jsi-base-coder

Expo

expo install react-native-jsi-base-coder
expo prebuild

Usage

Default behavior is using the base64Rfc4648 algorithm to encode/decode the data.

import { encode, decode } from 'react-native-jsi-base-coder';

// With the default algorithm in `base64Rfc4648`.
encode('Hello World!'); // SGVsbG8gV29ybGQh
decode('SGVsbG8gV29ybGQh'); // Hello World!

// With the Base32 algorithm with the `base32Rfc4648`.
encode('Hello World!', { algorithm: Algorithm.base32Rfc4648 }); // JBSWY3DPEBLW64TMMQQQ====
decode('JBSWY3DPEBLW64TMMQQQ====', { algorithm: Algorithm.base32Rfc4648 }); // Hello World!

API

encode

function (stringToEncode: string, config?: Config): string

Takes a string and returns an encoded string.

decode

Takes an encoded string and returns a decoded string.

function (bytesToDecode: string, config?: Config): string

config

The config object only take one property algorithm to define how you want to encode/decode your data. The default algorithm used is base64Rfc4648.

enum Algorithm {
  'base64Rfc4648' = 'base64Rfc4648',
  'base64Url' = 'base64Url',
  'base64UrlUnpadded' = 'base64UrlUnpadded',
  'base32Rfc4648' = 'base32Rfc4648',
  'base32Crockford' = 'base32Crockford',
  'base32Hex' = 'base32Hex',
  'base16Upper' = 'base16Upper',
  'base16Lower' = 'base16Lower',
}

encode('string to encode', { algorithm: Algorithm.base32Crockford });

Example

To run the development example you can use the following command:

cd example
yarn

Acknowledgements

License

MIT

react-native-jsi-base-coder's People

Contributors

jeremybarbet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

bytize-valli

react-native-jsi-base-coder's Issues

web support

would be nice to add a JS-only implementation in a .web.ts file. nice work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.