# react-native-seald-accelerator

Native module for Seald SDK

## Installation

```sh
npm install @seald-io/react-native-accelerator
```

## Usage

```js
import { generateSymkey, encryptFileAsString, decryptFileAsString } from "@seald-io/react-native-accelerator";

const symKey = await generateSymkey() // Generate AES Symmetric Key

// To encrypt a file
const messageId = "00000000-0000-1000-a000-1d0000000000"
const filename = "myFilename"
const utf8FileContent = "it's my file ! it's encrypted !"
const b64EncryptedFile = await encryptFileAsString(utf8FileContent, filename, messageId, symKey)

// To decrypt a file
const clearString = await decryptFileAsString(b64EncryptedFile, symKey)
const clearFile = JSON.parse(clearString)
console.log('clearFile.filename', clearFile.filename)
console.log('clearFile.messageId', clearFile.messageId)
console.log('clearFile.fileContent', clearFile.fileContent) // as utf8 string
```


## Dev

### init
installer [go](https://go.dev/doc/install), puis gomobile:
```
go install golang.org/x/mobile/cmd/gomobile@latest
```

Ajouter les executables go dans le path:
Linux `:/usr/local/go/bin:/home/$USER/go/bin`
Mac `export PATH=${PATH}:/Users/$USER/go/bin`


Installer le SDK et le NDK Android (`Android Studio` le fait très bien).
```tips
You may have to install the NDK (Obsolete) package in the Android SDK Manager (for which you will have to uncheck the "Hide obsolete tools" checkbox)
```

Télécharger les bibliothèques GO
```
./download-go-library.sh -e prod

# Pour télécharger les sources depuis different env, il faut utiliser l'option -e dev/limb/prod. Default to prod
./download-go-library.sh -e dev
```


Run the example project

```
cd example
npm run ios
npm run android

// If metro serveur is not automatically started:
npm run start
```


```tips
IOS: For every new go build, you need to run `pod install`
```
