openpgp 3.7.0 openpgp: ^3.7.0 copied to clipboard
library for use OpenPGP with support for android and ios, macOS, linux, windows and web
import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:openpgp/openpgp.dart';
import 'package:openpgp_example/encrypt_decrypt.dart';
import 'package:openpgp_example/encrypt_decrypt_bytes.dart';
import 'package:openpgp_example/encrypt_decrypt_file.dart';
import 'package:openpgp_example/encrypt_decrypt_symmetric.dart';
import 'package:openpgp_example/encrypt_decrypt_symmetric_bytes.dart';
import 'package:openpgp_example/generate.dart';
import 'package:openpgp_example/sign_verify.dart';
import 'package:openpgp_example/sign_verify_data.dart';
import 'package:openpgp_example/metadata.dart';
import 'package:openpgp_example/armor.dart';
import 'package:openpgp_example/convert.dart';
import 'package:openpgp_example/sign_verify_bytes.dart';
import 'package:openpgp_example/sign_verify_data_bytes.dart';
const passphrase = 'test';
void main() {
if (!kIsWeb && (Platform.isLinux || Platform.isWindows)) {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
}
runApp(new MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
const publicKey = '''
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: openpgp-mobile
xo0EYhESVwEEANJlqV1TdYvcKQbtMlW+L3cOIFT55YOVMfH0NMg9l0A8rSjJfir5
QL27McbEk0K4jFa0ZLM1DgFkOvw35qcIZ3YVMlBFiIeJMqRQUB/qzyGNS4cqN5Tj
TPK4zNVSjXF+Y0REA73/r9NGfG8vs7wEWOG/S6/eXomvcUQ4Htg4uMYLABEBAAHN
FHRlc3QgPHRlc3RAdGVzdC5jb20+wqgEEwEIABwFAmIRElcJEE00V8y9gx9zAhsD
AhkBAgsHAhUIAABmWAQABuX5cBVi0ZDZWdN4T0JELZF5S3Z8GUP7z8G53Mlum4ta
TUlc7qKGISEH8Rich/hxGdQsKp4llxOFS26v5lnkLBsAFTNhC1zJHW4FUpb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fZk3GpekO9EKCe/dNK6er1C8cHBydP5scwp8EGAEIABMFAmIR
ElcJEE00V8y9gx9zAhsMAAC6rQQAJs3VI07zIJJ3SVPWfHFigD7fHl9vMyEMAE4z
aBswFQ5YWzFAAQkoJhHp8Do9VnlFXg/DJcMi2R6q9ek08VcOOjiFeH44+0j1WhRA
XZxlM93SyqyGkXiHgVaRjpH4d/aLg0aH8COQRSVR/65Qe7mRc8pPHFHegxf5EsYF
4jAKyZI=
=x08A
-----END PGP PRIVATE KEY BLOCK-----
''';
class _MyAppState extends State<MyApp> {
KeyPair _defaultKeyPair = KeyPair(publicKey, privateKey);
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
if (_defaultKeyPair == null) {
return Container();
}
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('OpenPGP example app'),
),
body: ListView(
key: Key('list'),
children: <Widget>[
EncryptAndDecrypt(
title: "Encrypt And Decrypt",
keyPair: _defaultKeyPair,
key: Key("encrypt-decrypt"),
),
if (false)
EncryptAndDecryptFile(
title: "Encrypt And Decrypt file",
keyPair: _defaultKeyPair,
key: Key("encrypt-decrypt-file"),
),
EncryptAndDecryptBytes(
title: "Encrypt And Decrypt Bytes",
keyPair: _defaultKeyPair,
key: Key("encrypt-decrypt-bytes"),
),
EncryptAndDecryptSymmetric(
title: "Encrypt And Decrypt Symmetric",
keyPair: _defaultKeyPair,
key: Key("encrypt-decrypt-symmetric"),
),
EncryptAndDecryptSymmetricBytes(
title: "Encrypt And Decrypt Symmetric Bytes",
keyPair: _defaultKeyPair,
key: Key("encrypt-decrypt-symmetric-bytes"),
),
SignAndVerify(
title: "Sign And Verify",
keyPair: _defaultKeyPair,
key: Key("sign-verify"),
),
SignAndVerifyData(
title: "Sign And Verify Data",
keyPair: _defaultKeyPair,
key: Key("sign-verify-data"),
),
SignAndVerifyBytes(
title: "Sign And Verify Bytes",
keyPair: _defaultKeyPair,
key: Key("sign-verify-bytes"),
),
SignAndVerifyDataBytes(
title: "Sign And Verify Data Bytes",
keyPair: _defaultKeyPair,
key: Key("sign-verify-data-bytes"),
),
Generate(
title: "Generate",
key: Key("generate"),
),
Convert(
title: "Convert",
key: Key("convert"),
keyPair: _defaultKeyPair,
),
Metadata(
title: "Metadata",
key: Key("metadata"),
keyPair: _defaultKeyPair,
),
Armor(
title: "Armor",
key: Key("armor"),
),
],
),
),
);
}
}