import 'dart:convert';
import 'dart:typed_data';

import 'package:flutter/services.dart';

class EmailImageEncryption {
  static final EmailImageEncryption _instance = EmailImageEncryption._internal();
  static const MethodChannel _channel = MethodChannel('flutter_des');
  static const key = "PeShVmYp";
  static const iv = "j70IbWYn";

  EmailImageEncryption._internal();

  factory EmailImageEncryption() => _instance;

  Future<String> encrypt({required String val}) async {
    Uint8List? crypt = await _channel.invokeMethod('encrypt', [val, key, iv]);
    String enc = base64Encode(crypt!.toList());
    return enc;
  }

  Future<String> decrypt({required String encodedVal}) async {
    Uint8List deco = base64Decode(encodedVal);
    String? decCrypt = await _channel.invokeMethod('decrypt', [deco, key, iv]);
    return decCrypt!;
  }
}
