Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Time:2022-1-21

/ MD5 ( Message-Digest Algorithm ) /

MD5 message digest algorithm,Improved from MD4, MD3 and MD2, it mainly enhances the complexity and irreversibility of the algorithm, cryptographic hash function。 A 128 bit (16 characters (bytes)) hash value can be generated, and the 128 bit MD5 hash is represented as a 32-bit hexadecimal number to ensure complete and consistent transmission of information. It can be cracked to prove that MD5 algorithm can not prevent collision attack, so it is not suitable for security authentication, such as SSL public key authentication or digital signature. For highly secure data, SHA-2 algorithm can be used.

MD5 online encryption / MD5 free decryption / MD5 paid decryption

/MD5 verify signature/

The key can be any string. In order to increase the difficulty of cracking, the length of the key string negotiated between the client and the server should be as long as possible. A copy of the key is saved on the client and server respectively. The client obtains the timestamp, signature and other necessary parameters and adds them to the map set, and then arranges the map set according to the alphabetical order of the key. It is best to traverse the map set and obtain the key and value respectively, which are circularly spliced and assigned to a string variable. The spliced string is encrypted by MD5 algorithm by traversing the spliced key at the end of the spliced string.

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

/Timestamps prevent duplicate submissions/

Redis (replicate dictionary server) is a key value storage system and a cross platform non relational database. Open source key value database written in ANSI C language, complying with BSD protocol, supporting network, memory based, distributed and optional persistence. Redis is usually called a data structure server because values can be string, hash, list, sets, and sorted sets.

Obtain the time stamp stored in redius last time and compare it with the time stamp when the client initiates the request, so as to verify whether the time stamp is repeated and whether the session times out.

 Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

/The map collection is sorted alphabetically by key/

DartPad

Sorting algorithm

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

After sorting

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

/MD5 encryption/

Get Android platform key signature

Open the Android file} configuration key under the fluent project to} gradle properties (Project Properties)

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

build. Configure # fluttermd5key under gradle (corresponding alias: flutter_md5_key)

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

The Android studio menu bar compiles the project through build – > make project and generates a static and immutable key “fluent” under the buildconfig file_ MD5_ KEY 。

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Flutter establishes communication with Android native and obtains the key (flutter_md5_key)

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

In the main function call, you need to call the function ensuerinitialized(WidgetFlutterBindingUsed to interact with the flutter engine). Flutter obtains the key returned by Android native exchange_ MD5_ Key is added to the map set participating in the signature. Finally, traverse the set and splice the signature parameters for MD5 encryption.

WidgetsFlutterBinding.ensureInitialized();

pubspec. Configure common under yaml file_ Utils dependency Library (including MD5 encrypted tool classes)

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

 Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';

void main() async {
  ///Time stamp
  var _milSec = (DateTime.now().millisecondsSinceEpoch / 100).toStringAsFixed(0);
  ///Map collection
  Map<String, dynamic> encryMap = {
    'g_key': 'g_value',
    'b_key': 'b_value',
    'e_key': 'e_value',
    'a_key': 'a_value',
    'mil_sec':'$_milSec'
  };

  ///Map collection的键存储到 List 集合
  List<String> keys = encryMap.keys.toList();

  ///Map collection按照 key 排序
  keys.sort((a, b) {
    List<int> al = a.codeUnits;
    List<int> bl = b.codeUnits;
    for (int i = 0; i < al.length; i++) {
      if (bl.length <= i) return 1;
      if (al[i] > bl[i]) {
        return 1;
      } else if (al[i] < bl[i]) return -1;
    }
    return 0;
  });
  Print ('sorted key $keys \ n ');
  var _signStr = '';
  keys.asMap().forEach((k, v) {
    encryMap.forEach((pk, pv) {
      if (v == pk) {
        Print ('key set keys index $k set encrymap key $PK set encrymap value $PV ');
        _signStr += pk + "=" + '${pv ?? ''}' + "&";
      }
    });
  });
  WidgetsFlutterBinding.ensureInitialized();
  var _flutterNativeKeyValue = await FlutterPlugins.senData('flutterSendNavData');
  _signStr = _signStr.substring(0, _signStr.length - 1) + _flutterNativeKeyValue;
  ///Stitched signature parameters
  Print ('spliced signature parameter $_signstr ');

  var _encMdeSignStr=EncryptUtil.encodeMd5(_signStr);
  Print ('md5 signature: $_encmdesignastr ');
}

class FlutterPlugins {
  static const MethodChannel channel =
      const MethodChannel("com.flutter.native.key");

  static Future<String> senData(String result) async {
    return await channel.invokeMethod("flutterNativeKey", result);
  }
}

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

MD5 online encryptionVerify the signature algorithm of the dependent library

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Obtain IOS platform key signature

Use the Xcode tool to open the IOS folder in the fluent project and find appdelegate Open the swift} file, configure the key, and complete the process of obtaining the key from IOS

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
    
    
  var methodChannel:FlutterMethodChannel?
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
      
      ///Unique identifier of flutter and IOS communication com flutter. native. key
      let vc = self.window.rootViewController as! FlutterViewController
            self.methodChannel = FlutterMethodChannel.init(name: "com.flutter.native.key", binaryMessenger: vc.binaryMessenger)
            
      self.methodChannel!.setMethodCallHandler { (call , result) in
                ///Function called by fluent
                if(call.method == "flutterNativeKey"){
                    ///Key
                    result("qazwsxedcrfvtgbyhnujmikolp0987654321");
                }
            }
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Encryption parameters output from Xcode consoleActual combat network request MD5 + timestamp + verification signature Xi of fluent project

/Call so file/

Use this command to create the fluent project native in the current project directory_ add

flutter create --platforms=android,ios --template=plugin native_add

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Natvie created in_ Create “native” in the “classes” folder under the IOS folder in the add project_ add. Cpp file

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

native_ add. The key is configured in the cpp file

#include <stdint.h>
#include <string.h>


#define DART_API extern "C" __attribute__((visibility("default"))) __attribute__((used))
DART_API const char *greetString(const char *platform) {
    char _platform[]="android";
    if(strcmp(_platform,platform)==0){
        return "androidqazwsxedcrfvtgbyhnujmikolp0987654321";
    }
    return  "iosdqazwsxedcrfvtgbyhnujmikolp0987654321";
}

Natvie created in_ Create cmakelists under the # Android # folder in the add project Txt file is used to define how to compile source files and addexternalNativeBuildToandroid/build.gradle 

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

native_ Add project pubspec Configure FFI dependency Library under yaml file and complete dependency loading

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

native_ add. Import FFI dependency into dart} file, and load libnative on Android platform_ add. So library, which will be generated after project compilation So library file (under the path of build / native_add / intermediates / cmake / debug / obj)

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Run project view from native_ add. Key obtained by CPP

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

 

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Actual combat network request MD5 + timestamp + verification signature Xi of fluent project

Download case

Recommended Today

2021-11-09 volcano map based on RNA SEQ table (second time)

setwd(“C:\\Users\\Administrator.DESKTOP-4UQ3Q0K\\Desktop”) library(“readxl”) data <- read_excel(“RNA-seq.xlsx”) library(dplyr) library(ggplot2) library(ggrepel) data #Convert to tibble for subsequent use and remove unnecessary columns; Data < – Data [C (- 10, – 11, – 14, – 15, – 16, – 19, – 20, – 21, – 22)] # don’t try #data <- as_tibble(data[c(-10,-11,-14,-15,-16,-19,-20,-21,-22)]) data$padj<-as.numeric(as.matrix(data$padj)) #Take logarithm of Q value; data$log10FDR […]