openpgp 1.0.0 copy "openpgp: ^1.0.0" to clipboard
openpgp: ^1.0.0 copied to clipboard

outdated

library for use OpenPGP with support for android and ios, macOS, linux, windows, web and hover

OpenPGP #

Library for use openPGP with support for android, ios, macos, windows, linux, web and hover

Contents #

Usage #

Generate methods #

import 'package:openpgp/openpgp.dart';

void main() async {
    var keyOptions = KeyOptions()..rsaBits = 1024;
    var keyPair = await OpenPGP.generate(
            options: Options()
              ..name = 'test'
              ..email = 'test@test.com'
              ..passphrase = passphrase
              ..keyOptions = keyOptions);
}

Encrypt methods #

import 'package:fast_rsa/rsa.dart';

void main() async {

    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = await OpenPGP.encrypt("text","[publicKey here]");
    var result = await OpenPGP.encryptSymmetric("text","[passphrase here]");
    var result = await OpenPGP.encryptBytes(bytesSample,"[publicKey here]");
    var result = await OpenPGP.encryptSymmetricBytes(bytesSample,"[passphrase here]");

}

Decrypt methods #

import 'package:fast_rsa/rsa.dart';

void main() async {

    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = await OpenPGP.decrypt("text encrypted","[privateKey here]","[passphrase here]");
    var result = await OpenPGP.decryptSymmetric("text encrypted","[passphrase here]");
    var result = await OpenPGP.decryptBytes(bytesSample,"[privateKey here]","[passphrase here]");
    var result = await OpenPGP.decryptSymmetricBytes(bytesSample,"[passphrase here]");

}

Sign methods #

import 'package:fast_rsa/rsa.dart';

void main() async {

    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = await OpenPGP.sign("text","[publicKey here]","[privateKey here]","[passphrase here]");
    var result = await OpenPGP.signBytesToString(bytesSample,"[publicKey here]","[privateKey here]","[passphrase here]");

}

Verify methods #

import 'package:fast_rsa/rsa.dart';

void main() async {

    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = await OpenPGP.verify("text signed","text","[publicKey here]");
    var result = await OpenPGP.verifyBytes("text signed", bytesSample,"[publicKey here]");

}

Setup #

Android #

ProGuard

Add this lines to android/app/proguard-rules.pro for proguard support.

-keep class go.** { *; }
-keep class openpgp.** { *; }

iOS #

No additional setup required.

Web #

Web support right now is half progress, we need for support web workers. in order to make async calls.

Add to you pubspec.yaml.

assets:
  - packages/openpgp/web/assets/wasm_exec.js
  - packages/openpgp/web/assets/openpgp.wasm

ref: https://github.com/jerson/flutter-openpgp/blob/master/example/pubspec.yaml

and in you web/index.html

<script
  src="assets/packages/openpgp/web/assets/wasm_exec.js"
  type="application/javascript"
></script>

ref: https://github.com/jerson/flutter-openpgp/blob/master/example/web/index.html

MacOS #

No additional setup required.

Hover #

Update your plugins.

hover plugins get

In you main_desktop.dart by now you need to add OpenPGP.bindingEnabled = false in order to use channels instead of shared objects

import 'main.dart' as original_main;
import 'package:openpgp/openpgp.dart';

void main() {
  OpenPGP.bindingEnabled = false;
  original_main.main();
}

Linux #

No additional setup required.

Windows #

No additional setup required.

Example #

Inside example folder.

cd example && flutter run

Native Code #

Native library is made in Go for faster performance.

[https://github.com/jerson/openpgp-mobile]

37
likes
0
pub points
88%
popularity

Publisher

verified publisherjerson.dev

library for use OpenPGP with support for android and ios, macOS, linux, windows, web and hover

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

ffi, fixnum, flutter, flutter_web_plugins, js, protobuf

More

Packages that depend on openpgp