You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
content:Text('Do you want to export the private key?'),
93
+
actions: [
94
+
TextButton(
95
+
onPressed: () =>Navigator.pop(context, false),
96
+
child:Text('Cancel'),
97
+
),
98
+
TextButton(
99
+
onPressed: () =>Navigator.pop(context, true),
100
+
child:Text('Export'),
101
+
),
102
+
],
103
+
);
104
+
}
105
+
);
106
+
if (confirmed) {
107
+
final path =awaitFilePicker.platform.saveFile(fileName:'private_key-$uploaderName-${DateTime.now()}.asc', bytes:Uint8List.fromList(privateKey.codeUnits));
108
+
109
+
if (path !=null) {
110
+
awaitFile(path).writeAsString(privateKey);
111
+
}
112
+
}
113
+
}
114
+
115
+
116
+
Future<Uint8List> encryptPgpBytes(
117
+
Uint8List data,
118
+
String? armoredPublicKey,
119
+
) async {
120
+
if (armoredPublicKey ==null|| armoredPublicKey.isEmpty) {
121
+
return data;
122
+
}
123
+
124
+
final publicKey =OpenPGP.readPublicKey(armoredPublicKey);
125
+
final encrypted =OpenPGP.encryptBinaryData(data, encryptionKeys: [publicKey]);
126
+
final armored = encrypted.armor();
127
+
returnUint8List.fromList(utf8.encode(armored));
128
+
}
129
+
130
+
Stream<List<int>> encryptPgpStream(
131
+
Stream<List<int>> data,
132
+
String? armoredPublicKey,
133
+
) async* {
134
+
if (armoredPublicKey ==null|| armoredPublicKey.isEmpty) {
135
+
yield* data;
136
+
return;
137
+
}
138
+
139
+
final buffer =BytesBuilder();
140
+
awaitfor (final chunk in data) {
141
+
buffer.add(chunk);
142
+
}
143
+
144
+
final publicKey =OpenPGP.readPublicKey(armoredPublicKey);
145
+
final encrypted =OpenPGP.encryptBinaryData(buffer.toBytes(), encryptionKeys: [publicKey]);
0 commit comments