Awesome
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.
<img src="./misc/android_screenshot.png" width="250">Install
Android
- Get
age.aar
(You can getage.aar
from release page or clone the repo and executemake build-android
to build .aar yourself - Build artifact is located inbuild/android
folder.) - Add
age.aar
tolibs
folder in your app project - Include dependency for Android in
build.gradle
dependencies {
...
// AgeMobile aar from Go
implementation fileTree(include: ['age.aar'], dir: 'libs')
}
iOS
- Get
Age.xcframework
(You can getAge.xcframework
from release page or clone the repo and executemake build-ios
to build yourself - Build artifact is located inbuild/ios
folder.) - Copy
Age.xcframework
into iOS project framework folder - Import
Age
in Swift
Usage
Android
There is an example project in _examples/android folder
Generate key
import agemobile.Agemobile;
try {
age.X25519Identity identity = Agemobile.generateX25519Identity();
String privateKey = identity.string();
String publicKey = identity.recipient().string();
} catch (Exception e) {
e.printStackTrace();
}
Decrypt
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
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 folder
Generate Key
import Age
let identity = AgemobileGenerateX25519Identity(nil)
let privateKey = identity?.string()
let publicKey = identity?.recipient()?.string()
Encrypt
import Age
let input = "my secret"
let encrypted = AgemobileEncrypt(identity?.recipient()?.string(), input, true, nil)
Decrypt
import Age
let decrypted = AgemobileDecrypt(identity?.string(), encrypted, nil)
Contributing
PR's are welcome. Please read CONTRIBUTING.md for more info
License
MIT