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