44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
///
|
|
/// Enc/Dec JSON implementation
|
|
///
|
|
import 'dart:convert';
|
|
import 'package:letusmsg/ccc/crypto_abstract.dart';
|
|
|
|
|
|
/// Plaintext JSON codec used for testing/development flows.
|
|
///
|
|
/// This class intentionally does not provide cryptographic protection.
|
|
class EncDecJson implements CryptoAbstract<Map<String, dynamic>> {
|
|
|
|
@override
|
|
String get providerName => 'EncDecJson';
|
|
|
|
@override
|
|
bool get isPlaintextMode => true;
|
|
|
|
// @override
|
|
// List<int> pre(String input) {
|
|
// return utf8.encode(input);
|
|
// }
|
|
|
|
@override
|
|
Future<List<int>> encrypt(Map<String, dynamic> data, {CryptoContext? context}) async {
|
|
// Simulate encryption delay
|
|
// await Future.delayed(Duration(milliseconds: 100));
|
|
return utf8.encode( jsonEncode(data) );
|
|
}
|
|
|
|
@override
|
|
Future<Map<String, dynamic>> decrypt(List<int> encdata, {CryptoContext? context}) async {
|
|
// Simulate decryption delay
|
|
// await Future.delayed(Duration(milliseconds: 100));
|
|
return jsonDecode(utf8.decode(encdata));
|
|
}
|
|
|
|
// @override
|
|
// String post(List<int> output) {
|
|
// return utf8.decode(output);
|
|
// }
|
|
|
|
}
|