LCOV - code coverage report
Current view: top level - lib/_classes/controller - encryption_handler.dart Coverage Total Hit
Test: lcov.info Lines: 100.0 % 12 12
Test Date: 2026-11-14 15:04:37 Functions: - 0 0

            Line data    Source code
       1              : // Copyright 2023 The terCAD team. All rights reserved.
       2              : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3              : 
       4              : import 'dart:convert';
       5              : 
       6              : import 'package:app_finance/_classes/storage/app_preferences.dart';
       7              : import 'package:crypto/crypto.dart';
       8              : import 'package:encrypt/encrypt.dart';
       9              : 
      10              : class EncryptionHandler {
      11              :   static String prefNotEncrypted = 'false';
      12              : 
      13           12 :   static Encrypter get salt => Encrypter(AES(Key.fromUtf8('tercad-app-finance-by-vlyskouski')));
      14              : 
      15            6 :   static IV get code => IV.fromLength(8);
      16              : 
      17            2 :   static String getHash(Map<String, dynamic> data) {
      18            4 :     return getHashString(data.toString());
      19              :   }
      20              : 
      21            2 :   static String getHashString(String data) {
      22            6 :     return md5.convert(utf8.encode(data)).toString();
      23              :   }
      24              : 
      25            6 :   static bool doEncrypt() {
      26           12 :     return AppPreferences.get(AppPreferences.prefDoEncrypt) != prefNotEncrypted;
      27              :   }
      28              : 
      29            3 :   static String encrypt(String line) {
      30           12 :     return salt.encrypt(line, iv: code).base64;
      31              :   }
      32              : 
      33            2 :   static String decrypt(String line) {
      34            6 :     return salt.decrypt64(line, iv: code);
      35              :   }
      36              : }
        

Generated by: LCOV version 2.0-1