mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-24 07:00:47 -04:00
contact invitation algorithm
This commit is contained in:
parent
c35056f687
commit
f52094c105
43 changed files with 1319 additions and 451 deletions
25
lib/tools/secret_crypto.dart
Normal file
25
lib/tools/secret_crypto.dart
Normal file
|
@ -0,0 +1,25 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
import '../entities/local_account.dart';
|
||||
import '../veilid_support/veilid_support.dart';
|
||||
|
||||
Future<Uint8List> encryptSecretToBytes(
|
||||
{required SecretKey secret,
|
||||
required CryptoKind cryptoKind,
|
||||
EncryptionKeyType encryptionKeyType = EncryptionKeyType.none,
|
||||
String encryptionKey = ''}) async {
|
||||
final veilid = await eventualVeilid.future;
|
||||
|
||||
late final Uint8List identitySecretBytes;
|
||||
switch (encryptionKeyType) {
|
||||
case EncryptionKeyType.none:
|
||||
identitySecretBytes = secret.decode();
|
||||
case EncryptionKeyType.pin:
|
||||
case EncryptionKeyType.password:
|
||||
final cs = await veilid.getCryptoSystem(cryptoKind);
|
||||
|
||||
identitySecretBytes =
|
||||
await cs.encryptNoAuthWithPassword(secret.decode(), encryptionKey);
|
||||
}
|
||||
return identitySecretBytes;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue