Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,259 additions
and
861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
import 'package:openpgp/openpgp.dart'; | ||
import 'package:openpgp_example/main.dart'; | ||
import 'package:openpgp_example/shared/button_widget.dart'; | ||
import 'package:openpgp_example/shared/input_widget.dart'; | ||
import 'package:openpgp_example/shared/title_widget.dart'; | ||
|
||
class SignAndVerifyData extends StatefulWidget { | ||
const SignAndVerifyData({ | ||
Key? key, | ||
required this.title, | ||
required KeyPair? keyPair, | ||
}) : keyPair = keyPair, | ||
super(key: key); | ||
|
||
final KeyPair? keyPair; | ||
final String title; | ||
|
||
@override | ||
_SignAndVerifyDataState createState() => _SignAndVerifyDataState(); | ||
} | ||
|
||
class _SignAndVerifyDataState extends State<SignAndVerifyData> { | ||
String _signed = ""; | ||
String _verify = ""; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
padding: const EdgeInsets.all(10), | ||
child: Card( | ||
child: Column( | ||
children: [ | ||
TitleWidget(widget.title), | ||
InputWidget( | ||
title: "Sign", | ||
key: Key("sign"), | ||
result: _signed, | ||
onPressed: (controller) async { | ||
var result = await OpenPGP.signData( | ||
controller.text, | ||
widget.keyPair!.privateKey, | ||
passphrase, | ||
); | ||
setState(() { | ||
_signed = result; | ||
}); | ||
}, | ||
), | ||
ButtonWidget( | ||
title: "Verify", | ||
key: Key("verify"), | ||
result: _verify, | ||
onPressed: () async { | ||
var result = await OpenPGP.verifyData( | ||
_signed, | ||
widget.keyPair!.publicKey, | ||
); | ||
setState(() { | ||
_verify = result ? "VALID" : "INVALID"; | ||
}); | ||
}, | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import 'dart:convert'; | ||
import 'dart:typed_data'; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
import 'package:openpgp/openpgp.dart'; | ||
import 'package:openpgp_example/main.dart'; | ||
import 'package:openpgp_example/shared/button_widget.dart'; | ||
import 'package:openpgp_example/shared/input_widget.dart'; | ||
import 'package:openpgp_example/shared/title_widget.dart'; | ||
|
||
class SignAndVerifyDataBytes extends StatefulWidget { | ||
const SignAndVerifyDataBytes({ | ||
Key? key, | ||
required this.title, | ||
required KeyPair? keyPair, | ||
}) : keyPair = keyPair, | ||
super(key: key); | ||
|
||
final KeyPair? keyPair; | ||
final String title; | ||
|
||
@override | ||
_SignAndVerifyDataBytesState createState() => _SignAndVerifyDataBytesState(); | ||
} | ||
|
||
class _SignAndVerifyDataBytesState extends State<SignAndVerifyDataBytes> { | ||
String _signed = ""; | ||
String _signedBytes = ""; | ||
String _verify = ""; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
padding: const EdgeInsets.all(10), | ||
child: Card( | ||
child: Column( | ||
children: [ | ||
TitleWidget(widget.title), | ||
InputWidget( | ||
title: "Sign", | ||
key: Key("sign"), | ||
result: _signed, | ||
onPressed: (controller) async { | ||
var result = await OpenPGP.signDataBytes( | ||
Uint8List.fromList(controller.text.codeUnits), | ||
widget.keyPair!.privateKey, | ||
passphrase, | ||
); | ||
setState(() { | ||
_signed = base64Encode(result); | ||
}); | ||
}, | ||
), | ||
ButtonWidget( | ||
title: "Verify", | ||
key: Key("verify"), | ||
result: _verify, | ||
onPressed: () async { | ||
var result = await OpenPGP.verifyDataBytes( | ||
base64Decode(_signed), | ||
widget.keyPair!.publicKey, | ||
); | ||
setState(() { | ||
_verify = result ? "VALID" : "INVALID"; | ||
}); | ||
}, | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.