Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MarinX/agemobile
Gomobile support for Age
https://github.com/MarinX/agemobile
age-encryption android encryption golang ios-swift
Last synced: 25 days ago
JSON representation
Gomobile support for Age
- Host: GitHub
- URL: https://github.com/MarinX/agemobile
- Owner: MarinX
- License: mit
- Created: 2022-04-29T10:30:36.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-16T07:51:22.000Z (over 1 year ago)
- Last Synced: 2024-11-15T02:12:32.894Z (27 days ago)
- Topics: age-encryption, android, encryption, golang, ios-swift
- Language: Objective-C
- Homepage:
- Size: 12 MB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-age - agemobile
README
# agemobile
Gomobile bind is limited by types and while it allows you to generate identity, you cannot encrypt/decrypt.
This package wraps age library into usable mobile library.
## Install
### Android
1. Get `age.aar` (You can get `age.aar` from [release page](https://github.com/MarinX/agemobile/releases) or clone the repo and execute `make build-android` to build .aar yourself - Build artifact is located in `build/android` folder.)
2. Add `age.aar` to `libs` folder in your app project
3. Include dependency for Android in `build.gradle````gradle
dependencies {
...
// AgeMobile aar from Go
implementation fileTree(include: ['age.aar'], dir: 'libs')
}
```### iOS
1. Get `Age.xcframework` (You can get `Age.xcframework` from [release page](https://github.com/MarinX/agemobile/releases) or clone the repo and execute `make build-ios` to build yourself - Build artifact is located in `build/ios` folder.)
2. Copy `Age.xcframework` into iOS project framework folder
3. Import `Age` in Swift## Usage
### Android
There is an example project in [\_examples/android](./_examples/android/AgeMobile) folder
#### Generate key
```java
import agemobile.Agemobile;try {
age.X25519Identity identity = Agemobile.generateX25519Identity();
String privateKey = identity.string();
String publicKey = identity.recipient().string();
} catch (Exception e) {
e.printStackTrace();
}
```#### Decrypt
```java
import agemobile.Agemobile;// decrypt text
try {
String decryptedText = Agemobile.decrypt("age-key/s","with or without armor encrypted text");
} catch (Exception e) {
e.printStackTrace();
}// decrypt file
try {
Agemobile.decrypt("age-key/s","input file to decrypt", "output path where to write decrypted file");
} catch (Exception e) {
e.printStackTrace();
}
```#### Encrypt
```java
import agemobile.Agemobile;// encrypt text
try {
Agemobile.encrypt("age-keys","text to encrypt");
} catch (Exception e) {
e.printStackTrace();
}// encrypt file
try {
Agemobile.encryptFile("age-keys","input file to encrypt", "output path where to write encrypted file");
} catch (Exception e) {
e.printStackTrace();
}
```### iOS
There is an example project in [\_examples/ios](./_examples/ios/AgeMobile) folder
#### Generate Key
```swift
import Agelet identity = AgemobileGenerateX25519Identity(nil)
let privateKey = identity?.string()
let publicKey = identity?.recipient()?.string()```
#### Encrypt
```swift
import Agelet input = "my secret"
let encrypted = AgemobileEncrypt(identity?.recipient()?.string(), input, true, nil)
```#### Decrypt
```swift
import Agelet decrypted = AgemobileDecrypt(identity?.string(), encrypted, nil)
```## Contributing
PR's are welcome. Please read [CONTRIBUTING.md](https://github.com/MarinX/agemobile/blob/main/CONTRIBUTING.md) for more info
## License
MIT