2023-09-08 17:25:26 +00:00
|
|
|
import 'package:pigeon/pigeon.dart';
|
|
|
|
|
|
|
|
@ConfigurePigeon(
|
|
|
|
PigeonOptions(
|
|
|
|
dartOut: 'lib/pigeon/cryptography.g.dart',
|
2023-09-08 19:44:37 +00:00
|
|
|
kotlinOut:
|
|
|
|
'android/src/main/kotlin/org/moxxy/moxxy_native/cryptography/CryptographyApi.kt',
|
2023-09-08 17:25:26 +00:00
|
|
|
kotlinOptions: KotlinOptions(
|
|
|
|
package: 'org.moxxy.moxxy_native.cryptography',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
enum CipherAlgorithm {
|
|
|
|
aes128GcmNoPadding,
|
|
|
|
aes256GcmNoPadding,
|
|
|
|
aes256CbcPkcs7;
|
|
|
|
}
|
|
|
|
|
|
|
|
class CryptographyResult {
|
|
|
|
const CryptographyResult(this.plaintextHash, this.ciphertextHash);
|
|
|
|
final Uint8List plaintextHash;
|
|
|
|
final Uint8List ciphertextHash;
|
|
|
|
}
|
|
|
|
|
|
|
|
@HostApi()
|
|
|
|
abstract class MoxxyCryptographyApi {
|
|
|
|
@async
|
2023-09-08 19:44:37 +00:00
|
|
|
CryptographyResult? encryptFile(
|
|
|
|
String sourcePath,
|
|
|
|
String destPath,
|
|
|
|
Uint8List key,
|
|
|
|
Uint8List iv,
|
|
|
|
CipherAlgorithm algorithm,
|
|
|
|
String hashSpec,
|
|
|
|
);
|
2023-09-08 17:25:26 +00:00
|
|
|
|
|
|
|
@async
|
2023-09-08 19:44:37 +00:00
|
|
|
CryptographyResult? decryptFile(
|
|
|
|
String sourcePath,
|
|
|
|
String destPath,
|
|
|
|
Uint8List key,
|
|
|
|
Uint8List iv,
|
|
|
|
CipherAlgorithm algorithm,
|
|
|
|
String hashSpec,
|
|
|
|
);
|
2023-09-08 17:25:26 +00:00
|
|
|
|
|
|
|
@async
|
2023-09-08 19:44:37 +00:00
|
|
|
Uint8List? hashFile(
|
|
|
|
String sourcePath,
|
|
|
|
String hashSpec,
|
|
|
|
);
|
2023-09-08 17:25:26 +00:00
|
|
|
}
|