9/20/1
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'package:crypto/crypto.dart';
|
||||
|
||||
class AppCredintials {
|
||||
static const String basicAuthCredentials = 'hamzaayedphp:malDEV@2101';
|
||||
@@ -14,3 +15,35 @@ class AppCredintials {
|
||||
static const String transactionCloude =
|
||||
'Authorization:API_EMDJX6BHQ67DBGT6WV:DG2XPU7YEN02M0VJ2F';
|
||||
}
|
||||
|
||||
class MyClass {
|
||||
static const String mapAPIKEY = 'AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0';
|
||||
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
|
||||
Reference in New Issue
Block a user