A method, system, device and medium for synchronizing local messages with cloud messages

By generating synchronization requests containing rich information and encrypting data with dynamic keys, and adjusting the synchronization strategy based on network and battery status, the security and efficiency issues of cloud message synchronization are solved, achieving efficient and secure cross-platform data synchronization.

CN120614370BActive Publication Date: 2026-01-02BEIJING TONGDA XINKE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510556521.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2026-01-02
Estimated Expiration
2045-04-29

AI Technical Summary

Technical Problem

Existing cloud message synchronization mechanisms are inadequate in terms of security and user experience. Passwords are easily cracked, tokens are lost and need to be re-entered when switching devices, resulting in low synchronization efficiency.

Method used

It generates a synchronization request that includes synchronization direction, last synchronization time, network environment, and battery details. It uses biometric information, device identifiers, and geographic location to generate a dynamic key to encrypt the data. It also adjusts the synchronization strategy according to network and battery status, supports breakpoint resume and data compression, and builds a dynamic profile of contextual information to optimize transmission.

Benefits of technology

It improves the security and efficiency of message synchronization, optimizes resource utilization, ensures data reliability and timeliness, and provides good cross-platform compatibility and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120614370B_ABST
    Figure CN120614370B_ABST
Patent Text Reader

Abstract

The application discloses a method, system, device and medium for local message and cloud message synchronization, and relates to the technical field of communication. In the method, a synchronization request is generated; the synchronization request is sent to a cloud server, and it is judged whether response data returned by the cloud server can be received; if the response data returned by the cloud server can be received, a synchronization direction identifier is acquired, when the synchronization direction identifier is a first direction, first synchronization data is generated based on to-be-synchronized data; a dynamic key is generated based on biological feature information, a device identifier and geographical position information acquired by the local end, the first synchronization data is encrypted according to the dynamic key, and first target data is obtained; and the first target data is sent to the cloud server according to a current network environment type and current power details. The technical scheme provided by the application can effectively improve the security of data transmission.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of communication technology, in particular to a method for synchronizing local messages with cloud messages. BACKGROUND

[0002] With the rapid development of cloud computing, Internet of Things and mobile Internet technology, cloud message synchronization mechanism has become a key technology for various applications to realize data sharing and improve user experience. With the popularity of smart devices and the diversification of user needs, users have higher requirements for the security, real-time performance and convenience of message synchronization.

[0003] Currently, the mainstream cloud message synchronization mechanism mainly authenticates the identity of the user by inputting a password or token during the synchronization process. This method improves security to some extent, but there is a risk of password cracking or token loss. Moreover, when the user switches between different devices, the user needs to re-enter the password or token, which reduces the user experience.

[0004] Therefore, there is an urgent need for a message synchronization method that can improve message synchronization security while improving user experience and synchronization efficiency. SUMMARY

[0005] In order to ensure message synchronization security while improving user experience and synchronization efficiency, the present application provides a method, system, device and medium for synchronizing local messages with cloud messages.

[0006] In a first aspect of the present application, a method for synchronizing local messages with cloud messages is provided, which adopts the following technical solution:

[0007] A synchronization request is generated, which includes a synchronization direction identifier, last synchronization time information of the local end before the current time, network environment type and power details. The network environment type includes network mode, network bandwidth, delay and packet loss rate. The power details include power mode, remaining power and battery health;

[0008] The synchronization request is sent to a cloud server, and it is determined whether the response data returned by the cloud server can be received;

[0009] If the response data returned by the cloud server can be received, the synchronization direction identifier is obtained. When the synchronization direction identifier is a first direction, first synchronization data is generated based on the data to be synchronized;

[0010] A dynamic key is generated based on the obtained biometric information, device identifier and geographic location information. The first synchronization data is encrypted according to the dynamic key to obtain first target data;

[0011] According to the current network environment type and the current power details, the first target data is sent to the cloud server for synchronization.

[0012] By adopting the technical solution, the efficiency, security and user experience of local message and cloud message synchronization are significantly improved. Specifically, the scheme dynamically adjusts the synchronization strategy, intelligently selects the synchronization mode according to the network environment and power details, thereby improving the synchronization efficiency and optimizing the resource utilization. At the same time, the dynamic key generated by the biological feature information, the device identifier and the geographic location information is used to encrypt the synchronization data, thereby enhancing the security of the data. In addition, the scheme also supports functions such as breakpoint resume, data compression and decompression, thereby further improving the user experience. The checksum mechanism is used in the synchronization process to ensure data integrity, and has good cross-platform compatibility, and can support data synchronization between different operating systems and devices.

[0013] Optionally, the method further comprises:

[0014] If the response data returned by the cloud server is not received, the network mode and the power mode corresponding to the current time are determined;

[0015] When the network mode is a mobile network or the power mode is a power saving state, the to-be-synchronized data is compressed to form first cache data, and the first cache data is stored in a local cache queue;

[0016] When the network mode is Wi-Fi and the power mode is not a power saving state, first synchronization data is generated based on the first cache data.

[0017] By adopting the technical solution, the flow can be saved, the energy consumption can be reduced, and the reliability of the synchronization data can be ensured.

[0018] Optionally, the method further comprises:

[0019] When the synchronization direction identifier is a second direction, the second target data transmitted by the cloud server is received;

[0020] The second target data is decrypted according to the dynamic key to obtain second synchronization data;

[0021] The local database and the local log are updated according to the second synchronization data.

[0022] By adopting the technical solution, when the synchronization direction identifier is a second direction, the local end receives the second target data transmitted by the cloud server, and the dynamic key generated before is used to decrypt the data, thereby obtaining the second synchronization data. This process not only ensures the integrity and security of the cloud transmission data, but also realizes the traceability of data synchronization by updating the local database and the local log.

[0023] Optionally, the dynamic key is generated based on the biometric information, the device identifier and the geographic location information obtained by the local end, and specifically includes:

[0024] performing a hash operation on the biometric information to generate a first key factor;

[0025] splicing the device identifier and the last synchronization time information to generate intermediate information, and performing a hash operation on the first key factor and the intermediate information to generate a second key factor;

[0026] converting the geographic location information into a latitude and longitude hash value to generate a third key factor;

[0027] combining the first key factor, the second key factor and the third key factor according to a preset rule to generate a dynamic key.

[0028] By adopting the above dynamic key generation technical solution, firstly, the uniqueness and non-replicability of biometric information are utilized to generate a first key factor through a hash operation, which provides a basic security guarantee for the key. Subsequently, the device identifier and the last synchronization time information are spliced and then subjected to a hash operation to generate a second key factor, which not only enhances the dynamic nature of the key, but also effectively prevents replay attacks. In addition, the geographic location information is converted into a latitude and longitude hash value to generate a third key factor, which further expands the randomness and unpredictability of the key. Finally, the three key factors are efficiently combined according to a preset rule, which not only ensures the complexity of key generation, but also ensures the fast response of the generation process. This hierarchical and progressive key generation mechanism, while taking into account security, achieves exponential expansion of the key space through multi-factor fusion and the efficiency of hash operation, effectively resisting brute force attacks and other attack methods, and building a multi-level protection system for data transmission.

[0029] Optionally, the first synchronization data is encrypted according to the dynamic key, and specifically includes:

[0030] generating an encryption block parameter according to the dynamic key, the encryption block parameter including a block size and an iteration number;

[0031] cutting the first synchronization data according to the block size to obtain block data, and encrypting the block data in combination with a timestamp and the encryption block parameter;

[0032] appending a check code to the encrypted block data, the check code being generated from the dynamic key and a device real-time state parameter, the device real-time state parameter including network delay, CPU load and battery level.

[0033] By adopting the technical scheme, first, the encrypted block parameters are generated according to the dynamic key, including the block size and the iteration number, the block size is reasonably set, the encryption efficiency and the memory occupation are effectively balanced, and the large file encryption can also be efficiently performed. Then, the first synchronous data is cut according to the block size, and is encrypted in combination with the time stamp and the encryption parameter, the introduction of the time stamp enhances the dynamic nature of the encryption process, and effectively prevents the replay attack. Finally, the check code is attached to the encrypted block data, the check code is generated by the dynamic key and the real-time state parameter of the device, not only the integrity of the data is ensured, but also the check code is difficult to be predicted or tampered through the dynamic change of the real-time state parameter, a double protection mechanism is built for the data transmission. The combination of the block encryption and the dynamic check not only improves the encryption efficiency, but also enhances the anti-attack ability of the data in the transmission process, and provides a solid guarantee for the system security.

[0034] Optionally, the cutting of the first synchronous data according to the block size to obtain block data specifically comprises:

[0035] monitoring the CPU occupation rate and the memory remaining amount;

[0036] if the CPU occupation rate is higher than a first threshold value, judging whether the memory remaining amount is lower than a second threshold value;

[0037] if the memory remaining amount is not lower than the second threshold value, increasing the block size;

[0038] if the memory remaining amount is lower than the second threshold value, decreasing the block size.

[0039] By adopting the technical scheme, the current system resource state is intelligently perceived by monitoring the CPU occupation rate and the memory remaining amount in real time. When the CPU occupation rate is higher than a first threshold value, the memory remaining amount is further judged: if the memory is not lower than a second threshold value, the block size is increased, the data amount of single encryption processing is increased by reducing the block quantity, and the encryption efficiency is improved; if the memory is lower than the second threshold value, the block size is decreased, the memory occupation of single encryption operation is reduced, and the system crash or the sharp performance decline caused by the memory overflow is avoided. The dynamic block adjustment mechanism based on the real-time state of the system not only optimizes the encryption efficiency, but also reasonably allocates the system resources, effectively prevents the deterioration of the system performance in the high-load scene, and provides a reliable guarantee for the stable operation of the device under the high-intensity encryption task.

[0040] Optionally, the sending of the first target data to the cloud server according to the current network environment type and the current power details specifically comprises:

[0041] constructing a scenario information dynamic portrait according to the network environment type and the power details;

[0042] based on the scenario information dynamic portrait, calling a preset transmission strategy optimization model to obtain transmission parameters, the transmission parameters including a transmission protocol and a transmission rate;

[0043] sending the first target data to the cloud server through the transmission parameters.

[0044] By adopting the technical solution, first, the scenario information dynamic portrait is constructed in combination with the current network environment type and the power details, accurately reflecting the characteristics of the current transmission environment. Then, based on the portrait, a preset transmission strategy optimization model is called, which dynamically generates transmission parameters, including selecting the optimal transmission protocol and determining the best transmission rate, through machine learning or rule engine, comprehensive analysis of network bandwidth, delay, packet loss rate and power consumption rate and other multi-dimensional parameters. This combination of scenario awareness and transmission optimization not only improves the data transmission efficiency, but also balances the traffic and energy consumption through intelligent decision-making, significantly improving the endurance of the device in different use scenarios, and bringing a more intelligent and efficient transmission experience to the user.

[0045] In a second aspect of the application, a system for synchronizing local messages with cloud messages is provided, specifically comprising:

[0046] a synchronization request generation module for generating a synchronization request, the synchronization request containing a synchronization direction identifier, last synchronization time information of the local end before the current time, network environment type and power details, the network environment type including network mode, network bandwidth, delay and packet loss rate, the power details including power mode, remaining power and battery health degree;

[0047] a request transmission module for sending the synchronization request to the cloud server and determining whether the response data returned by the cloud server can be received;

[0048] a synchronization direction determination module for, if the response data can be received, obtaining the synchronization direction identifier, and when the synchronization direction identifier is a first direction, generating first synchronization data based on the data to be synchronized;

[0049] an encryption module for generating a dynamic key based on the obtained biometric information, device identifier and geographic location information, encrypting the first synchronization data according to the dynamic key to obtain first target data;

[0050] a data transmission module for sending the first target data to the cloud server for synchronization according to the current network environment type and the current power details.

[0051] In a third aspect of the present application, an electronic device is provided, comprising a processor, a memory, a user interface and a network interface, the memory is configured to store instructions, the user interface and the network interface are configured to communicate with other devices, and the processor is configured to execute the instructions stored in the memory to enable the electronic device to perform the method according to any one of the preceding aspects.

[0052] In a fourth aspect of the present application, a computer-readable storage medium is provided, which stores instructions that, when executed, perform the method according to any one of the preceding aspects.

[0053] In summary, the one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:

[0054] The synchronization request containing rich information such as synchronization direction, local synchronization time, network environment and power details is generated, and the synchronization data is encrypted based on a dynamic key, which greatly enhances the security of data transmission. At the same time, the synchronization strategy can be flexibly adjusted according to the network mode and the power state, which saves traffic and reduces energy consumption while ensuring the reliability and timeliness of the synchronization data. In addition, by constructing a dynamic portrait of situational information and calling a transmission strategy optimization model, the network environment and the power state are cooperatively perceived, which further optimizes the synchronization efficiency and provides users with a smoother and safer synchronization experience. BRIEF DESCRIPTION OF DRAWINGS

[0055] Figure 1 is a system architecture schematic diagram of an embodiment of a local message and cloud message synchronization method or system according to the present application;

[0056] Figure 2 is a flowchart of a local message and cloud message synchronization method disclosed in an embodiment of the present application;

[0057] Figure 3 is a module schematic diagram of a local message and cloud message synchronization system disclosed in an embodiment of the present application;

[0058] Figure 4 is a structure schematic diagram of an electronic device disclosed in an embodiment of the present application.

[0059] Legend of reference signs: 301, synchronization request generation module; 302, request transmission module; 303, synchronization direction determination module; 304, encryption module; 305, data transmission module; 401, processor; 402, communication bus; 403, user interface; 404, network interface; 405, memory. DETAILED DESCRIPTION

[0060] In order for those skilled in the art to better understand the technical solutions in the specification, the technical solutions in the specification will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the specification. Obviously, the described embodiments are only some of the embodiments of the present application, not all the embodiments.

[0061] In the description of the embodiments of the present application, the words such as "for example" or "for instance" are used to represent an example, illustration or description. Any embodiment or design scheme described as "for example" or "for instance" in the embodiments of the present application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. Rather, the words such as "for example" or "for instance" are intended to present the relevant concept in a specific manner.

[0062] In the description of the embodiments of the present application, the term "a plurality of" means two or more. For example, a plurality of systems means two or more systems, and a plurality of screen terminals means two or more screen terminals. In addition, the terms "first" and "second" are used only for the purpose of description, and should not be interpreted as indicating or implying relative importance or implicitly indicating the indicated technical features. Therefore, the features defined with "first" and "second" can explicitly or implicitly include one or more of the features. The terms "include", "contain", "have" and their variants mean "include but are not limited to", unless otherwise specifically emphasized.

[0063] As shown in Figure 1 The system architecture 100 can include terminal devices 101, 102, 103, a network 104 and a cloud server 105. The network 104 is used to provide a communication link medium between the terminal devices 101, 102, 103 and the cloud server 105. The network 104 can include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0064] A user can use the terminal devices 101, 102, 103 to interact with the cloud server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 101, 102, 103, such as model training applications, video recognition applications, web browser applications, social platform software, etc.

[0065] The terminal device 101, 102, 103 can be hardware or software. When the terminal device 101, 102, 103 is hardware, it can be various electronic devices with a display screen, including but not limited to a smart phone, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III) player, an MP4 (Moving Picture Experts Group Audio Layer IV) player, a laptop computer, a desktop computer, and the like. When the terminal device 101, 102, 103 is software, it can be installed in the above-listed electronic devices. It can be implemented as multiple software or software modules (for example, multiple software or software modules for providing distributed services) or as a single software or software module. No specific limitation is made herein.

[0066] When the terminal 101, 102, 103 is hardware, a video capture device can also be installed thereon. The video capture device can be various devices capable of capturing video, such as a camera, a sensor, and the like. A user can capture video using the video capture device on the terminal 101, 102, 103.

[0067] The cloud server 105 can be a server providing various services, for example, a background server for processing data displayed on the terminal device 101, 102, 103. The background server can analyze and process received data, and can feed back the processing result (for example, a recognition result) to the terminal device.

[0068] It should be noted that the cloud server can be hardware or software. When the cloud server is hardware, it can be implemented as a distributed server cluster composed of multiple servers or as a single server. When the cloud server is software, it can be implemented as multiple software or software modules (for example, multiple software or software modules for providing distributed services) or as a single software or software module. No specific limitation is made herein.

[0069] It should be understood that Figure 1 The number of terminal devices, networks, and cloud servers in the system architecture is only illustrative. According to the implementation needs, there can be any number of terminal devices, networks, and cloud servers. In particular, in the case where the target data does not need to be obtained from a remote place, the above system architecture can not include a network, but only include a terminal device or a cloud server.

[0070] The embodiment discloses a method for synchronizing local messages and cloud messages, applied to a local end, Figure 2This is a flowchart illustrating a method for synchronizing local and cloud messages disclosed in an embodiment of this application. Figure 2 As shown, the method includes the following steps:

[0071] S201. Generate a synchronization request. The synchronization request includes a synchronization direction identifier, the last synchronization time information of the local terminal before the current time, network environment type, and battery details. The network environment type includes network mode, network bandwidth, latency, and packet loss rate. The battery details include battery mode, remaining battery power, and battery health.

[0072] Specifically, the synchronization direction identifier clarifies the data flow direction of this synchronization operation. The last synchronization time information of the local end before the current moment refers to the record with the largest timestamp selected from the log, which is the last successful synchronization time of the local end before the current moment. The network environment type includes network mode, such as WiFi and mobile network; network bandwidth, such as uplink / downlink rate; network latency, i.e., network round-trip time; and packet loss rate, i.e., the proportion of data packets lost. Battery details include battery mode, such as performance mode, standard mode, and power saving mode; remaining battery power, i.e., battery percentage; and battery health, i.e., the degree of battery wear and cycle count. The local end serializes the obtained synchronization direction identifier, last synchronization time information, network environment type, and battery details in JSON (JavaScript Object Notation) format to construct a synchronization request.

[0073] Furthermore, when initiating the synchronization process, the synchronization direction is first determined based on business needs or user settings. The local log table is queried to obtain the last successful synchronization time before the current moment. The network interface of the local device is used to detect the current network connection status in real time, obtaining the network mode (e.g., Wi-Fi, 4G, 5G), network bandwidth, latency, and packet loss rate. This information is encapsulated into a network environment type object and used as one of the fields in the synchronization request. By calling the battery management API (Application Programming Interface) of the local device, the current power mode of the device is obtained, such as power saving mode, balanced mode, and performance mode, the remaining power percentage, and battery health. The obtained synchronization direction identifier, last synchronization time information, network environment type, and power details are assembled into a synchronization request data packet in JSON format.

[0074] Further, when assembling the synchronization request data packet, the contents of each field are determined in the following order: the first field is the synchronization direction identifier, with a value such as upload or download, indicating the direction of data flow; the second field is the last synchronization time, recorded in the ISO 8601 date and time format, such as 2023-10-01T12: 00: 00Z; the third field is the network environment type, including information such as network mode, bandwidth, delay, and packet loss rate, such as WiFi, 100 Mbps, 50 ms, and 0.1%; the fourth field is the power details, covering power mode, remaining power percentage, and battery health, such as balanced mode, 80%, and good; finally, all the information is packaged into JSON format in this order, i.e. the assembly of the synchronization request data packet is completed.

[0075] S202, send the synchronization request to the cloud server and determine whether the response data returned by the cloud server can be received;

[0076] Specifically, the response data refers to the data returned by the cloud server after processing the synchronization request sent by the local end, which is used to determine whether the current cloud server is online. The local end device first attempts to establish a network connection with the cloud server according to the preset cloud server address and port number. For example, using HTTP (Hypertext Transfer Protocol) or HTTPS (Hypertext Transfer Protocol Secure), by creating a corresponding TCP (Transmission Control Protocol) connection, the synchronization request object generated in step S201 is serialized and converted into a format that can be transmitted in the network, such as a JSON string or a binary data stream, and then the serialized synchronization request data is sent to the cloud server through the established network connection.

[0077] Further, after sending the synchronization request, the local end device sets a timeout time, which is adjusted according to network conditions, business needs, and other factors to ensure waiting for the response of the cloud server within a reasonable time. Within the timeout time, the local end device continuously listens for data from the cloud server on the network connection. If the cloud server returns response data within the timeout time, it is determined that the response data can be received, indicating that the cloud server is online; if the cloud server does not return response data within the timeout time, it is determined that the response data cannot be received, indicating that the cloud server may not be online or there may be other network problems.

[0078] S203, if the response data returned by the cloud server can be received, obtain the synchronization direction identifier, and when the synchronization direction identifier is the first direction, generate first synchronization data based on the data to be synchronized;

[0079] Specifically, the first direction refers to transmitting data from the local terminal device to the cloud server, the data to be synchronized refers to data to be transmitted from the local terminal device to the cloud server in the synchronization operation, and the first synchronization data refers to data obtained by processing and packaging the data to be synchronized based on the data to be synchronized when the synchronization direction is the first direction.

[0080] Further, after receiving the response data returned by the cloud service area, it is judged whether the synchronization direction identifier is the first direction. If it is the first direction, the data to be synchronized is first located and extracted from the local terminal, such as new contact information in the address book, which is converted into a standard format such as JSON format, and data verification is completed. The obtained data to be synchronized is preprocessed, such as removing invalid data, classifying and arranging data, etc., to obtain the first synchronization data.

[0081] Optionally, the method further comprises:

[0082] If the response data returned by the cloud server is not received, the network mode and the power mode corresponding to the current time are determined.

[0083] When the network mode is a mobile network or the power mode is a power saving state, the data to be synchronized is compressed to form first cache data, and the first cache data is stored in the local cache queue.

[0084] When the network mode is Wi-Fi and the power mode is not a power saving state, the first synchronization data is generated based on the first cache data.

[0085] Specifically, if the response data returned by the cloud server is not received after a specified timeout, the current network mode and the current power mode are determined. When it is detected that the current network mode is a mobile network or the power mode is in a power saving state, considering the possibility of mobile network traffic fees and the limited device performance in the power saving state, the system will compress the data to be synchronized. The compression algorithm is selected according to the data type and characteristics, such as using gzip algorithm for text data and JPEG compression algorithm for image data. The first cache data formed after compression will be stored in the local cache queue. The local cache queue usually uses a first-in, first-out (FIFO) storage strategy to ensure that data is processed in the order of sending. At the same time, in order to facilitate subsequent management and processing, relevant metadata is added to each cache data, such as data generation time, data type, target synchronization object, etc.

[0086] Further, when the network mode is Wi-Fi and the power mode is not the power saving state, it indicates that the current network environment is stable and the device performance is good, and has the conditions for directly performing data synchronization. At this time, the system obtains the first cache data stored in the local cache queue in advance, decompresses the first cache data to restore the original to-be-synchronized data, and determines the first synchronization data through the to-be-synchronized data.

[0087] Optionally, the method further comprises:

[0088] When the synchronization direction identifier is the second direction, receiving the second target data transmitted by the cloud server;

[0089] Decrypting the second target data according to the dynamic key to obtain second synchronization data;

[0090] Updating the local database and the local log according to the second synchronization data.

[0091] Specifically, the local end listens to the data transmission of the cloud server through the established communication connection, such as WebSocket or HTTP long polling. Once the cloud server has second target data to be synchronized to the local end, the local end receives the data. During the receiving process, the size of the receiving buffer is dynamically adjusted according to the network environment and power details to improve the receiving efficiency and stability.

[0092] Further, after the local end receives the second target data, it first parses the data format and extracts the dynamic key information from the data. The dynamic key information is transmitted separately from the data to ensure the security of the key. During the extraction process, the dynamic key is extracted according to the predetermined key information position or identifier. After the dynamic key is extracted, the local end uses the key to decrypt the second target data. The decryption process uses a symmetric encryption algorithm such as AES-256. During decryption, the algorithm performs inverse operations on the data according to the key and the initialization vector (IV) to convert the ciphertext into plaintext. After decryption, the local end verifies the decryption result, such as calculating the hash value of the decrypted data and comparing it with the hash value sent by the cloud server, to ensure the integrity and correctness of the data.

[0093] After decryption and verification, the local end compares and merges the second synchronization data with the existing data in the local database. During the comparison process, it is determined whether the data is a new, modified or deleted operation according to the unique identifier of the data. If it is a new or modified operation, the local end inserts or updates the second synchronization data into the local database; if it is a deletion operation, the corresponding data in the local database is deleted. After the update is completed, the local end records the related information of the synchronization process in the local log.

[0094] S204, generate a dynamic key based on the obtained biometric information, device identifier and geographic location information, encrypt the first synchronization data according to the dynamic key to obtain first target data;

[0095] Specifically, the biometric information refers to the biometric information that is unique to an individual, measurable physiological or behavioral characteristics, used for identity verification and identification, the device identifier refers to a code or string used to uniquely identify a specific device, and the geographic location information refers to the specific location coordinates of the device on the earth, usually represented by longitude and latitude.

[0096] Optionally, the dynamic key is generated based on the biometric information, device identifier and geographic location information obtained by the local end, and specifically includes:

[0097] Hashing the biometric information to generate a first key factor;

[0098] Splicing the device identifier and the last synchronization time information to generate intermediate information, and hashing the first key factor and the intermediate information to generate a second key factor;

[0099] Convert the geographic location information into a latitude and longitude hash value to generate a third key factor;

[0100] Combining the first key factor, the second key factor and the third key factor according to a preset rule to generate a dynamic key.

[0101] Specifically, in this embodiment, a fingerprint is used as biometric information, and a fingerprint recognition sensor is used to scan and collect features such as fingerprint lines, breakpoints and bifurcation points, to generate fingerprint image data. The fingerprint image data is subjected to preliminary filtering, enhancement and other operations by the processing circuit inside the sensor to improve the clarity and recognizability of the fingerprint features. The processed fingerprint image data is stored in row priority, each pixel value is converted to binary bit, and binary fingerprint image data is formed. A SHA-256 hash function is selected, the binary data is taken as input, and a fixed length hash value is calculated by the hash function, which is the first key factor.

[0102] Further, the device identifier and the last synchronization time information are spliced, the synchronization time information is accurate to the millisecond level, and the time identifier of each synchronization operation is unique. The splicing method uses simple string connection, for example, the device identifier and the synchronization time information are directly connected together to form a longer string as intermediate information. The first key factor and the above generated intermediate information are hashed, and the first key factor and the intermediate information are spliced as input for operation to obtain the second key factor.

[0103] Further, the latitude and longitude are converted into GeoHash code, first determine the latitude and longitude range (latitude-90 to 90 degrees, longitude-180 to 180 degrees), then the latitude and longitude are converted into binary representation, then the binary bits of latitude and longitude are alternately combined to form a new binary code, and finally the interleaved binary code is divided into groups of 5 bits, and each group is converted into corresponding Base32 characters, thereby obtaining the GeoHash code, for example, the coordinate (31.2304°N, 121.4737°E) is converted into "wtw3sjzw", the SHA-256 hash algorithm is used, the code is taken as an input parameter for calculation, the input parameter is padded to meet the length requirement, the padded information is divided into multiple blocks, each block is subjected to cyclic right shift and modulo addition operation, and finally the processing results of all blocks are combined to obtain a 256-bit hash value, that is, the third key factor.

[0104] Further, a 3x3 matrix is generated, first, the first key factor, the second key factor and the third key factor are filled into three different positions of a 3x3 matrix, for example, the first key factor is placed in the upper left corner of the matrix, the second key factor is placed in the center of the matrix, and the third key factor is placed in the lower right corner of the matrix. A 90-degree rotation operation is performed on the matrix, each row of the matrix becomes a column, and the original column becomes a row, thereby changing the position of the elements. After rotation, the matrix is scaled by multiplying a scaling factor, so that the value of each element is enlarged or reduced in proportion. Then, the matrix is subjected to a shearing transformation, that is, the matrix is tilted in a certain direction, so that the elements in the matrix are displaced, increasing the complexity of the matrix. After completing all the above transformations, the matrix is unfolded in row or column order to form a one-dimensional key sequence, that is, a dynamic key.

[0105] Optionally, the encryption according to the dynamic key includes:

[0106] According to the dynamic key, an encryption block parameter is generated, the encryption block parameter includes a block size and an iteration number;

[0107] The first synchronization data is cut into block data according to the block size, and the block data is encrypted in combination with a timestamp and the encryption block parameter;

[0108] A check code is attached to the encrypted block data, the check code is generated from the dynamic key and a device real-time state parameter, and the device real-time state parameter includes network delay, CPU load and battery capacity.

[0109] Specifically, the dynamic key is taken as an input, and the block size and the iteration number are generated by a specific algorithm or function. For example, the dynamic key can be subjected to a hash operation, and a part of the hash value is taken as the block size and another part is taken as the iteration number. Then, the first synchronization data is cut according to the generated block size. If the data length is not an integer multiple of the block size, the last block needs to be padded to reach the block size. The padding mode adopts the PKCS#7 padding, that is, a number of bytes are filled at the end of the last block, and the value of each byte is equal to the number of filled bytes.

[0110] Further, for each block data, the current timestamp and the encrypted block parameter are combined to encrypt by using a symmetric encryption algorithm. In the embodiment, the symmetric encryption algorithm is selected as the AES algorithm. In the encryption process, the timestamp and the iteration number are taken as additional parameters of the encryption algorithm to enhance the complexity and security of the encryption. For example, the timestamp and the iteration number are spliced in front of or behind the block data, and then the encryption is performed. A check code is attached to each encrypted block data. The check code is generated by the dynamic key and the real-time state parameter of the device, and the real-time state parameter of the device includes the network delay, the CPU load and the battery capacity, etc. The hash algorithm is used to generate the check code. The dynamic key and the real-time state parameter of the device are spliced as an input, and a fixed-length hash value is calculated by the hash algorithm, which is the check code. The generated check code is attached to the corresponding encrypted block data to form the final encrypted data block.

[0111] Optionally, the cutting of the first synchronization data according to the block size to obtain block data specifically includes:

[0112] monitoring the CPU occupancy rate and the memory remaining amount;

[0113] if the CPU occupancy rate is higher than a first threshold value, determining whether the memory remaining amount is lower than a second threshold value;

[0114] if the memory remaining amount is not lower than the second threshold value, increasing the block size;

[0115] if the memory remaining amount is lower than the second threshold value, decreasing the block size.

[0116] Specifically, the CPU occupancy rate and the memory remaining amount are monitored in real time through a battery management API of the local terminal device. If the CPU occupancy rate is higher than a first threshold value, it is determined whether the memory remaining amount is lower than a second threshold value. The first threshold value and the second threshold value can be preset according to the actual situation of the system. For example, the first threshold value can be set to 80%, and the second threshold value can be set to 200 MB. If the memory remaining amount is not lower than the second threshold value, it indicates that there is sufficient memory resource for use. At this time, the block size can be increased, so as to reduce the number of blocks, thereby reducing the calculation overhead and the memory access times in the encryption process, and improving the encryption efficiency. The increasing amplitude can be preset according to the actual situation of the system. For example, the block size can be increased to twice the original size. If the memory remaining amount is lower than the second threshold value, it indicates that the system memory resource is relatively tight. At this time, the block size should be reduced, so as to increase the number of blocks, thereby reducing the memory space occupied by each block in the encryption process, and avoiding the problem of insufficient memory. The decreasing amplitude can be preset according to the actual situation of the system. For example, the block size can be reduced to half the original size.

[0117] S205、According to the current network environment type and the current power details, the first target data is sent to the cloud server.

[0118] Optionally, the sending of the first target data to the cloud server according to the current network environment type and the current power details further includes:

[0119] According to the network environment type and the power details, a scenario information dynamic portrait is constructed.

[0120] Based on the scenario information dynamic portrait, a preset transmission strategy optimization model is called to obtain transmission parameters, the transmission parameters including a transmission protocol and a transmission rate.

[0121] The first target data is sent to the cloud server through the transmission parameters.

[0122] Specifically, the current network type and the power percentage are obtained in real time by calling a device system API. The network type is mapped to a theoretical bandwidth value, for example, Wi-Fi = 100 Mbps, 5G = 50 Mbps. The network stability score is calculated based on the packet loss rate and the delay fluctuation standard deviation. The calculation formula is Where f(x) is the stability score, y is the packet loss rate, and z is the standard deviation of delay fluctuation; at the same time, the power value is classified into three levels: high (≥70%), medium (30%-70%), and low (≤30%), and the remaining transmission time is predicted by combining the device power consumption model. The above parameters are packaged into a structured JSON dynamic image, including network type, bandwidth, stability, power level, and remaining time, which are input into the rule engine for decision-making. If the device is in a low power state and not charging, the UDP protocol is forced to be selected to reduce connection overhead, the transmission rate is limited to 40% of the theoretical bandwidth, and single-thread serial transmission is limited; if the device is connected to Wi-Fi and the stability score is ≥0.85, the multiplexing feature of the HTTP / 3 protocol is enabled, allowing 4 threads to be started concurrently at a rate of 90% of the theoretical bandwidth, and if the device is on a mobile network and the power is ≥50%, the TCP protocol is selected to ensure reliability, the rate is limited to 70% of the bandwidth, and the number of concurrent threads is set to 2.

[0123] Further, during transmission, the sliding window flow control and selective retransmission mechanism are used in TCP mode, CRC32 checksum is added to each data block in UDP mode, and 0-RTT handshake is enabled in HTTP / 3 mode to reduce delay; rate control is achieved through the token bucket algorithm, which fills the token bucket with a rate of 125KB per millisecond, for example, when the speed limit is 90Mbps, 11.25MB tokens are filled per second, and tokens matching the block size must be deducted before sending data, otherwise it will be blocked and wait for filling; the thread pool configures independent threads to process block data according to the number of concurrent threads, for example, 4 threads are processed simultaneously when 4 threads are concurrent. In real-time monitoring, if the delay of 3 consecutive blocks exceeds 200ms or the power drops to 10%, the degradation strategy is triggered immediately, i.e. the number of concurrent threads is forced to 1, the rate is reduced to 80% of the current value, and the breakpoint position and failed block index are recorded. When the network recovers, retry the failed blocks at intervals of 1s, 2s, and 4s, if it fails for 3 times in a row, pause the transmission and record the error log, and notify the user to intervene.

[0124] The embodiment also discloses a system for synchronizing local messages and cloud messages, Figure 3 is a module schematic diagram of a local message and cloud message synchronization system disclosed by the embodiment of the application, as Figure 3 indicated, the system comprises:

[0125] The synchronization request generation module 301 is configured to generate a synchronization request, wherein the synchronization request comprises a synchronization direction identifier, last synchronization time information of the local end before the current time, a network environment type, and power details, the network environment type comprises a network mode, a network bandwidth, a delay, and a packet loss rate, and the power details comprise a power mode, a remaining power, and a battery health degree.

[0126] The request transmission module 302 is configured to send the synchronization request to a cloud server and determine whether response data returned by the cloud server can be received;

[0127] The synchronization direction determination module 303 is configured to, if the response data can be received, acquire a synchronization direction identifier, and generate first synchronization data based on the data to be synchronized when the synchronization direction identifier is a first direction.

[0128] The encryption module 304 is configured to generate a dynamic key based on acquired biological feature information, a device identifier and geographic location information, encrypt the first synchronization data according to the dynamic key, and obtain first target data.

[0129] The data transmission module 305 is configured to send the first target data to the cloud server according to a current network environment type and current power details.

[0130] Optionally, the system further includes a local cache module 306, which is specifically configured to:

[0131] If the response data returned by the cloud server is not received, a network mode and a power mode corresponding to a current time are determined.

[0132] When the network mode is a mobile network or the power mode is a power saving state, the data to be synchronized is compressed to form first cache data, and the first cache data is stored in a local cache queue.

[0133] When the network mode is Wi-Fi and the power mode is not the power saving state, first synchronization data is generated based on the first cache data.

[0134] Optionally, the system further includes a decryption module 307, which is specifically configured to:

[0135] When the synchronization direction identifier is a second direction, second target data transmitted by the cloud server is received.

[0136] The second target data is decrypted according to the dynamic key to obtain second synchronization data.

[0137] The local database and the local log are updated according to the second synchronization data.

[0138] Optionally, the encryption module 304 is specifically configured to:

[0139] The biological feature information is subjected to a hash operation to generate a first key factor.

[0140] The device identifier is spliced with the last synchronization time information to generate intermediate information, the first key factor and the intermediate information are subjected to a hash operation to generate a second key factor;

[0141] The geographic location information is converted into a latitude and longitude hash value to generate a third key factor;

[0142] The first key factor, the second key factor and the third key factor are combined according to a preset rule to generate a dynamic key.

[0143] Optionally, the encryption module 304 is specifically configured to:

[0144] According to the dynamic key, an encryption block parameter is generated, and the encryption block parameter includes a block size and an iteration number;

[0145] The first synchronization data is cut according to the block size to obtain block data, and the block data is encrypted in combination with a timestamp and the encryption block parameter;

[0146] A check code is attached to the encrypted block data, and the check code is generated from the dynamic key and a device real-time state parameter, and the device real-time state parameter includes a network delay, a CPU load and a battery capacity.

[0147] Optionally, the encryption module 304 is specifically configured to:

[0148] The CPU occupancy and the memory remaining amount are monitored;

[0149] If the CPU occupancy is higher than a first threshold value, it is determined whether the memory remaining amount is lower than a second threshold value;

[0150] If the memory remaining amount is not lower than the second threshold value, the block size is increased;

[0151] If the memory remaining amount is lower than the second threshold value, the block size is decreased.

[0152] Optionally, the data transmission module 305 is specifically configured to:

[0153] According to the network environment type and the power details, a scenario information dynamic portrait is constructed;

[0154] Based on the scenario information dynamic portrait, a preset transmission strategy optimization model is called to obtain transmission parameters, and the transmission parameters include a transmission protocol and a transmission rate;

[0155] The first target data is sent to the cloud server through the transmission parameters.

[0156] It should be noted that the apparatus provided in the above embodiments is only exemplified by the above division of functional modules when realizing its functions, and in actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above described functions. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.

[0157] The embodiment also discloses an electronic device, referring to Figure 4 The electronic device can include at least one processor 401, at least one communication bus 402, a user interface 403, a network interface 404, and at least one memory 405.

[0158] The communication bus 402 is used to realize the connection and communication between the components.

[0159] The user interface 403 can include a display screen (Display) and a camera (Camera), and the optional user interface 403 can further include a standard wired interface and a wireless interface.

[0160] The network interface 404 can optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).

[0161] The processor 401 can include one or more processing cores. The processor 401 connects various parts of the server through various interfaces and lines, executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 405, and calling data stored in the memory 405. Optionally, the processor 401 can be realized in at least one of the hardware forms of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 401 can integrate a combination of one or several of central processing units (Central Processing Unit, CPU), graphics processing units (Graphics Processing Unit, GPU), and modems. Among them, the CPU mainly processes operating systems, user interfaces, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; and the modem is used for processing wireless communication. It can be understood that the above-mentioned modem can also not be integrated into the processor 401, but can be realized by a separate chip.

[0162] The memory 405 can include a Random Access Memory (RAM) and can also include a Read-Only Memory (ROM). Optionally, the memory 405 includes a non-transitory computer-readable storage medium. The memory 405 can be used to store instructions, programs, codes, code sets, or instruction sets. The memory 405 can include a program storage area and a data storage area, where the program storage area can store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, etc.; the data storage area can store data involved in the various method embodiments described above, etc. The memory 405 can optionally be at least one storage device located away from the aforementioned processor 401. As shown, the memory 405, as a computer storage medium, can include an operating system, a network communication module, a user interface module, and an application for synchronizing local messages and cloud messages. Figure 4 As shown, the memory 405, as a computer storage medium, can include an operating system, a network communication module, a user interface module, and an application for synchronizing local messages and cloud messages.

[0163] In the electronic device shown, the user interface 403 is mainly used to provide an interface for user input and obtain data input by the user; and the processor 401 can be used to call the application for synchronizing local messages and cloud messages stored in the memory 405, and when executed by the one or more processors 401, cause the electronic device to perform the method of one or more of the above embodiments. Figure 4 As shown, the memory 405, as a computer storage medium, can include an operating system, a network communication module, a user interface module, and an application for synchronizing local messages and cloud messages.

[0164] It should be noted that, for the above method embodiments, in order to simply describe, they are all described as a series of action combinations, but those skilled in the art should know that the present application is not limited to the action sequence described, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0165] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the relevant description of other embodiments.

[0166] In several embodiments provided in the present application, it should be understood that the disclosed apparatus can be implemented in other manners. For example, the division of the apparatus embodiments is merely illustrative, and the division of units can be changed according to actual conditions, such as a combination or integration of some units, or a deletion of some features, or an addition of some features. In addition, the coupling or direct coupling or communication connection between the shown or discussed units can be indirect coupling or communication connection through some interfaces, devices or units, and can be in electrical, mechanical or other forms.

[0167] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one place or distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0168] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0169] If the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable memory. Based on this understanding, the technical solutions of the present application essentially or the part of the prior art that contributes to the technical solutions or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a memory 405 and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the embodiments of the present application. The aforementioned memory 405 includes: a U disk, a mobile hard disk, a magnetic or optical disk, and various media that can store program codes.

[0170] The above is merely exemplary embodiments of the present disclosure, and cannot limit the scope of the present disclosure. That is, any equivalent changes and modifications made in accordance with the teachings of the present disclosure are still within the scope of the present disclosure. Other embodiments of the present disclosure will be readily apparent to those skilled in the art upon considering the disclosure herein. The present application is intended to cover any variations, uses or adaptive changes of the present disclosure that follow the general principles of the present disclosure and include common knowledge or conventional techniques in the art that are not described in the present disclosure. The scope and spirit of the present disclosure are defined by the claims. The specification and embodiments are merely exemplary, and the scope and spirit of the present disclosure are defined by the claims.

Claims

1. A method for synchronizing local messages and cloud messages, characterized in that, Applied to a local device, the method includes: A synchronization request is generated, which includes a synchronization direction identifier, the last synchronization time information of the local terminal before the current time, network environment type, and battery details. The network environment type includes network mode, network bandwidth, latency, and packet loss rate. The battery details include battery mode, remaining battery power, and battery health. The synchronization request is sent to the cloud server, and it is determined whether the response data returned by the cloud server can be received. If the response data returned by the cloud server can be received, the synchronization direction identifier is obtained. When the synchronization direction identifier is the first direction, the first synchronization data is generated based on the data to be synchronized. A dynamic key is generated based on the acquired biometric information, device identifier, and geographic location information. The first synchronization data is then encrypted using the dynamic key to obtain the first target data. The first target data is sent to the cloud server for synchronization based on the current network environment type and the current battery details. The step of sending the first target data to the cloud server for synchronization based on the current network environment type and the current battery details also includes: A dynamic profile of the scenario information is constructed based on the network environment type and the battery details; Based on the dynamic profile of the scenario information, a preset transmission strategy optimization model is invoked to obtain transmission parameters, including transmission protocol and transmission rate; The first target data is sent to the cloud server using the transmission parameters.

2. The method according to claim 1, characterized in that, The method further includes: If no response data is received from the cloud server, determine the current network mode and power mode. When the network mode is mobile network or the power mode is power saving, the data to be synchronized is compressed to form the first cache data, and the first cache data is stored in the local cache queue. When the network mode is Wi-Fi and the power mode is not in power-saving mode, first synchronization data is generated based on the first cached data.

3. The method according to claim 1, characterized in that, The method further includes: When the synchronization direction is identified as the second direction, the second target data transmitted by the cloud server is received. The second target data is decrypted using the dynamic key to obtain the second synchronization data; Update the local database and local logs based on the second synchronized data.

4. The method according to claim 1, characterized in that, The generation of the dynamic key based on the acquired biometric information, device identifier, and geographic location information includes: The biometric information is hashed to generate a first key factor; The device identifier is concatenated with the last synchronization time information to generate intermediate information. The first key factor and the intermediate information are hashed to generate the second key factor. The geographical location information is converted into latitude and longitude hash values ​​to generate a third key factor; The first key factor, the second key factor, and the third key factor are combined according to a preset rule to generate a dynamic key.

5. The method according to claim 1, characterized in that, The step of encrypting the first synchronization data according to the dynamic key further includes: The encryption block parameters are generated based on the dynamic key, and the encryption block parameters include the block size and the number of iterations; The first synchronization data is divided into block data according to the block size, and the block data is encrypted by combining the timestamp and the encryption block parameters; A checksum is attached to the encrypted data blocks. The checksum is generated by the dynamic key and the device's real-time status parameters, which include network latency, CPU load, and battery level.

6. The method according to claim 5, characterized in that, The step of dividing the first synchronized data according to the block size to obtain block data further includes: Monitor CPU usage and remaining memory; If the CPU utilization rate is higher than the first threshold, determine whether the remaining memory is lower than the second threshold. If the remaining memory is not lower than the second threshold, increase the block size; If the remaining memory is lower than the second threshold, the block size is reduced.

7. A system for synchronizing local messages and cloud messages, characterized in that, Specifically, it includes: A synchronization request generation module is used to generate a synchronization request. The synchronization request includes a synchronization direction identifier, the last synchronization time information of the local end before the current time, network environment type, and battery details. The network environment type includes network mode, network bandwidth, latency, and packet loss rate. The battery details include battery mode, remaining battery power, and battery health. The request transmission module is used to send the synchronization request to the cloud server and determine whether the response data returned by the cloud server can be received. The synchronization direction determination module is used to obtain the synchronization direction identifier if the response data can be received, and generate first synchronization data based on the data to be synchronized when the synchronization direction identifier is a first direction. An encryption module is used to generate a dynamic key based on the acquired biometric information, device identifier, and geographic location information, and to encrypt the first synchronization data according to the dynamic key to obtain the first target data; The data transmission module is used to send the first target data to the cloud server according to the current network environment type and the current battery details. The data transmission module is also configured to: A dynamic profile of the scenario information is constructed based on the network environment type and the battery details; Based on the dynamic profile of the scenario information, a preset transmission strategy optimization model is invoked to obtain transmission parameters, including transmission protocol and transmission rate; The first target data is sent to the cloud server using the transmission parameters.

8. An electronic device, characterized in that, The device includes a processor, a memory, a user interface, and a network interface. The memory is used to store instructions. The user interface and the network interface are both used to communicate with other devices. The processor is used to execute the instructions stored in the memory to cause the electronic device to perform the method as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed, perform the method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Method and system for synchronizing information of mobile terminal and server

    CN106131147A

  • Data synchronization method and apparatus

    CN106487798A