import 'dart:convert';
import 'package:crypto/crypto.dart';

class AppCredintials {
  static const String basicAuthCredentials = 'hamzaayedphp:malDEV@2101';
  static const String serverAPI =
      'AAAAinYllCo:APA91bF1shTpzSsSxqbfY6c60D8zs1ZsdIsl9ix6nl7GDdjCqWPRK0G0ub5SqFdb1jDpQDvQPxGg-697MWLo0sy3oYImBwBLObyhk0GjtNzyr0PbE3hI-pOvhf8Vp1xgUgBmofbZYXkH';
// AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0
  static const String mapAPIKEY = 'AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0';
  static const String twilloRecoveryCode = 'TQF13XUVU2NJ3VFU8JWBWYBS';
  static const String accountSIDTwillo = 'ACb4ad857efe0903bfd6238a763a2ce4d1';
  static const String authTokenTwillo = '14f39ef4628bb8a4f18469f462f8af75';
  static const String Publishablekey = '14f39ef4628bb8a4f18469f462f8af75';
  String getBasicAuthCredentials() {
    return base64Encode(utf8.encode(basicAuthCredentials));
  }

  static const String transactionCloude =
      'Authorization:API_EMDJX6BHQ67DBGT6WV:DG2XPU7YEN02M0VJ2F';
}

class StripeKey {
  static const String publishableKey =
      'pk_test_51O4WTODMEVrOCA5SN5e6b8pAvF5CPDC3c3Pif18q74NEQApU5AfmZZEN9X2WIayfIrUTjju1pUavmgoeLgb3FR5k00pn4oMHGO';
  static const String secretKey =
      'sk_test_51O4WTODMEVrOCA5SBgaoSS69nNFRyfZx2Tl5ODswYyjqLpc0RxBHW3hhcP38Tp78TZ1PQoZo7eHFllRiQd3rMHPN00Lr9WD3n2';
}

class MyClass {
  static const String mapAPIKEY = 'AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0';
  static const String twilloRecoveryCode = 'TQF13XUVU2NJ3VFU8JWBWYBS';
  static const String accountSIDTwillo = 'ACb4ad857efe0903bfd6238a763a2ce4d1';
  static const String authTokenTwillo = '14f39ef4628bb8a4f18469f462f8af75';
  static const String additionalText = 'additional text';

  String getBasicAuthCredentials() {
    return base64Encode(utf8.encode(mapAPIKEY));
  }

  String removeAddedText(String apiKey, String addedText) {
    final hashedText = sha256.convert(utf8.encode(addedText)).toString();
    return apiKey.replaceAll(hashedText, '');
  }

  String addTextToAPIKey(String apiKey, String textToAdd) {
    final hashedText = sha256.convert(utf8.encode(textToAdd)).toString();
    final midIndex = apiKey.length ~/ 2;
    final firstHalf = apiKey.substring(0, midIndex);
    final secondHalf = apiKey.substring(midIndex);
    return '$firstHalf$hashedText$secondHalf';
  }

  void exampleUsage() {
    String modifiedAPIKey = addTextToAPIKey(mapAPIKEY, additionalText);
    print('Modified API Key: $modifiedAPIKey');

    String finalAPIKey = removeAddedText(modifiedAPIKey, additionalText);
    print('Final API Key: $finalAPIKey');
  }
}
//  Modified API Key: AIzaSyCyfwRXTwSTLOFc57cb9e210a21def772cad3cd9ef83247e70bed77da89a64c9a5e91e7f3348dbQSQgN5p7QZgGJVZnEKq0
// I/flutter ( 5490): Final API Key: AIzaSyCyfwRXTwSTLOFc57cb9e210a21def772cad3cd9ef83247e70bed77da89a64c9a5e91e7f3348dbQSQgN5p7QZgGJVZnEKq0
