A method and system for fast text encryption and decryption in input methods

By analyzing user input data in real time and dynamically calculating the encryption urgency index using semantic continuity and exponential decay models, the encryption timing is adaptively determined, solving the balance problem between user experience and data security in input method encryption technology and achieving efficient text encryption and decryption.

CN120632918BActive Publication Date: 2026-04-03国投云网数字科技有限公司 +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-13
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing input method encryption technologies are insufficient in balancing user experience and data security. Fixed buffer strategies are difficult to adapt to differences in user habits and fluctuations in device performance, resulting in encryption response delays or misjudgments, which affect input fluency and privacy protection levels.

Method used

By analyzing the time interval between user input characters, the number of unencrypted characters, and device load rate in real time, and using semantic continuity analysis and exponential decay model, the encryption delay acceptance and urgency index are dynamically calculated to adaptively determine when to encrypt. Combined with the AES encryption algorithm, this enables fast encryption and decryption of text.

Benefits of technology

Without requiring user intervention, it effectively balances input fluency and data security, improving the privacy protection level and input experience of the input method, and solving the shortcomings of traditional fixed strategies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120632918B_ABST
    Figure CN120632918B_ABST
Patent Text Reader

Abstract

This application relates to the field of data security technology, specifically to a method and system for fast text encryption and decryption for input methods. The method includes: based on the encryption delay acceptance rate at all times within a preset time period prior to each time, using an exponentially weighted moving average algorithm to obtain an exponentially decaying weighted value at each time point to classify encryption preferences at each time point; based on the dispersion of the encryption delay acceptance rate at all times within the preset time period prior to each time point, and combined with the encryption preference classification results at each time point, determining the encryption urgency index at each time point, and encrypting the text input by the input method at the current time point. This application solves the drawbacks of fixed buffer strategies in balancing the impact of dynamic encryption, improving the privacy protection level and input fluency of the input method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data security technology, specifically to a method and system for fast text encryption and decryption for input methods. Background Technology

[0002] Against the backdrop of widespread mobile internet adoption and frequent privacy breaches, input methods, as the core entry point for text input, face increasingly prominent risks of transmitting plaintext content. Traditional encryption mechanisms often involve complex operations and performance degradation, compromising the immediacy and smoothness of the input experience. Therefore, fast text encryption / decryption technology has emerged, aiming to achieve localized or low-latency encryption of characters within the input box the instant a key is pressed. The ciphertext is then seamlessly decrypted and restored at the receiving end. This provides imperceptible protection for sensitive information such as account passwords, ID numbers, and medical records entered in scenarios like chat, email, and finance, without interrupting the input stream or altering user habits. This significantly improves privacy and security, enhances public confidence in the digital space, and contributes to building a more reliable communication ecosystem.

[0003] There are two main methods for fast encryption in input methods: character-by-character encryption, while secure, destroys semantics, affects intelligent prediction, and is vulnerable to attacks; word-buffered encryption, while preserving context, struggles to determine when encryption will be triggered, and differences in user habits and device performance can lead to the risk of plaintext exposure. Existing technologies mainly address the shortcomings of dynamic context-aware buffer partial buffering encryption, but the algorithm for dynamically adjusting the buffer size highly depends on user behavior modeling and real-time calculation. Under the influence of differences in user typing habits and low-performance devices, encryption response delays or misjudgments may occur, reducing the level of privacy protection and input fluency of the input method. Summary of the Invention

[0004] To address the aforementioned technical problems, the purpose of this application is to provide a method and system for fast text encryption and decryption in input methods. The specific technical solution adopted is as follows:

[0005] In a first aspect, embodiments of this application provide a method for fast text encryption and decryption for input methods, the method comprising the following steps:

[0006] During the editing process on the terminal device, the system can obtain in real time the characters the user types on the input method keyboard, the load rate of the terminal device, and the number of unencrypted characters in the encrypted buffer of the input method keyboard, as well as the time interval between each character and its predecessor.

[0007] Based on the analysis of all characters at all times within the preset time period before each time point and the time interval between each character and its previous character, a semantic continuity analysis algorithm is used to determine the semantic coherence probability value at each time point; based on the number of unencrypted characters at all times within the preset time period before each time point and the load rate of the terminal device, an exponential decay model is used to determine the cumulative number of characters at each time point, and combined with the semantic coherence probability value, the encryption delay acceptance rate at each time point is determined.

[0008] Based on the encryption delay acceptance rate at all times within the preset time period before each time, the exponentially weighted moving average algorithm is used to obtain the exponential decay weighted value at each time to classify encryption preferences at each time. Based on the dispersion of encryption delay acceptance rate at all times within the preset time period before each time, the encryption urgency at each time is determined. Combined with the encryption preference classification results at each time, the encryption urgency index at each time is determined.

[0009] Based on the encryption urgency index at the current moment, the text input by the current input method is encrypted.

[0010] Preferably, the method for determining the semantic coherence probability value at each time point is as follows:

[0011] The input of the semantic continuity analysis algorithm is to take all characters at all times within the preset time period before each time and the time interval between each character and its predecessor. The characters at all times are used as hidden state nodes in the state transition probability matrix of the semantic continuity analysis algorithm, and the time interval between each character and its predecessor is used as the weight factor of the hidden state node in the state transition probability matrix. The likelihood probability at each time is output as the semantic coherence probability at each time.

[0012] Preferably, the method for determining the cumulative character amount at each time point is as follows:

[0013] The number of unencrypted characters and the load rate of the terminal device within the preset time period before each time are used as inputs to the exponential decay model. The number of unencrypted characters within the preset time period before each time is used as the base of the exponential decay model, and the load rate of the terminal device within the preset time period before each time is used as the decay constant of the exponential decay model. The decay value at each time is output as the cumulative number of characters at each time.

[0014] Preferably, the encryption delay acceptance at each time point is the normalized value of the ratio of the semantic coherence probability value to the character change rate at each time point.

[0015] Preferably, the method for obtaining the exponentially decaying weighted values ​​at each time point is as follows:

[0016] The encryption delay acceptance rate at all times within a preset time period before each time is used as the input of the exponentially weighted decay average algorithm. The decay coefficient is set to a preset value, the sliding window is set to a preset length, and the exponentially decayed weighted value at any time within the preset time period before each time is output. By traversing all times, the exponentially decayed weighted value at each time is obtained.

[0017] Preferably, the classification of encryption preferences at each time point includes:

[0018] Encryption preferences include three types: instant encryption, normal encryption, and deferred encryption, with labels set to 2, 1, and 0 respectively.

[0019] If the normalized value of the exponentially decaying weighted value at time i is less than the preset first value, then the label of the encryption preference at time i is set to 2.

[0020] If the normalized value of the exponentially decaying weighted value at time i is greater than the preset second value, then the label of the encryption preference at time i is set to 0.

[0021] If the normalized value of the exponentially decaying weighted value at time i is between a preset first value and a preset second value, then the label of the encryption preference at time i is set to 1, where the preset first value is less than the preset second value; traverse all times to obtain the encryption preference classification at any time.

[0022] Preferably, the encryption urgency at each time point is the coefficient of variation of the encryption delay acceptance at all times within a preset time period prior to each time point.

[0023] Preferably, the expression for the encryption urgency index at each time point is: In the formula, This represents the encryption urgency index at time i; This represents the encryption preference label value at time i; The urgency of encryption at a given time is indicated by ; norm[ ] represents the normalization function.

[0024] Preferably, encrypting the text input by the input method at the current moment includes:

[0025] If the current encryption urgency index is greater than the preset urgency threshold, the AES symmetric encryption algorithm is immediately used to batch encrypt all contents of the encryption buffer. Otherwise, the AES encryption algorithm is used to encrypt the contents of the encryption buffer when the user inputs punctuation or a newline.

[0026] Secondly, embodiments of this application also provide a fast text encryption / decryption system for an input method, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of any of the above-described fast text encryption / decryption methods for an input method.

[0027] This application has at least the following beneficial effects:

[0028] This application addresses the challenge of balancing user experience and data security in input method encryption. By analyzing real-time user input data, including character time intervals, the number of unencrypted characters, and device load, it utilizes semantic continuity analysis algorithms and an exponential decay model to calculate a semantic coherence probability value reflecting the integrity of input content and a character accumulation value indicating potential data leakage risk. Combining these two values, an encryption delay acceptability is constructed to intelligently determine whether delayed encryption is appropriate. This adapts to different user habits and device performance, effectively balancing input fluency and data security without user intervention, thus solving the problem of traditional fixed... To address the shortcomings of fixed-buffer strategies, this application analyzes users' recent input patterns and security margins, uses an exponentially weighted moving average to determine users' preference for delayed encryption, and combines the instability of the input stream to assess the urgency of encryption, ultimately obtaining an encryption urgency index. This index adaptively determines when to encrypt: when the risk is high or the semantics are incoherent, encryption is performed immediately to ensure security; when the risk is low and the semantics are coherent, encryption is delayed until the natural pause point to maintain fluency. This effectively solves the drawbacks of fixed-buffer strategies, achieving the best balance between data security and input experience without user intervention, and improving the privacy protection level and input fluency of the input method. Attached Figure Description

[0029] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0030] Figure 1 A flowchart illustrating the steps of a fast text encryption / decryption method for an input method provided in one embodiment of this application;

[0031] Figure 2 This is a schematic diagram illustrating the encryption urgency index extraction process provided in one embodiment of this application. Detailed Implementation

[0032] To further illustrate the technical means and effects adopted by this application to achieve the intended inventive purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of the text fast encryption and decryption method and system for input methods proposed in this application. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.

[0033] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.

[0034] The following description, in conjunction with the accompanying drawings, details the specific scheme of the fast text encryption / decryption method and system for input methods provided in this application.

[0035] Please see Figure 1 The diagram illustrates a flowchart of a fast text encryption / decryption method for an input method according to an embodiment of this application. The method includes the following steps:

[0036] Step S1: During the editing process on the terminal device, the system obtains in real time the characters the user types on the input method keyboard, the load rate of the terminal device, and the number of unencrypted characters in the encrypted buffer of the input method keyboard, and obtains the time interval between each character and its predecessor.

[0037] A keystroke detection sensor is installed in the keyboard event-driven layer of the input method framework to capture the characters that the user types on the input method keyboard in real time during the editing process on the terminal device, and to obtain the time interval between each character and its previous character; in particular, if no key is pressed continuously, the captured character is set to an empty value, and when the next keystroke occurs, the time interval between the next keystroke and its most recent keystroke is obtained for subsequent analysis.

[0038] A character counter is set in the memory management unit of the input method keyboard encryption buffer to collect the number of unencrypted characters currently accumulated in the buffer in real time.

[0039] A CPU monitor is installed at the device hardware level to collect real-time CPU load rate, which is used to dynamically assess the system resources' ability to support encryption operations.

[0040] It should be noted that the acquisition frequency of all the above sensors is set to f, and all the above data are acquired synchronously in real time. The acquisition frequency f is set manually. In this embodiment, the acquisition frequency f is 20Hz. In actual application, as other implementation methods, implementers can also set it according to specific circumstances. This embodiment does not impose any special restrictions.

[0041] Step S2: Based on the analysis of all characters at all times within the preset time period before each time point and the time interval between each character and its previous character, a semantic continuity analysis algorithm is used to determine the semantic coherence probability value at each time point; based on the number of unencrypted characters at all times within the preset time period before each time point and the load rate of the terminal device, an exponential decay model is used to determine the cumulative number of characters at each time point, and combined with the semantic coherence probability value, the encryption delay acceptance rate at each time point is determined.

[0042] Due to the high degree of variation in user input habits and the significant fluctuations in terminal device performance, traditional fixed buffers or simple triggering mechanisms face core challenges in fast text encryption systems for input methods. They struggle to accurately determine the actual encryption process. Encrypting too early can disrupt semantics and impair intelligent prediction functions, while encrypting too late exposes sensitive characters in plaintext form for too long, significantly increasing data security risks and making them vulnerable to malicious processes that may snoop or intercept them, leading to serious data security incidents.

[0043] Therefore, in order to find a suitable encryption time to balance user experience and data security, this embodiment analyzes the characters at all times within a preset time period before each time point and the time interval between each character and its predecessor. A semantic continuity analysis algorithm is used to determine the semantic coherence probability value at each time point. Based on the number of unencrypted characters at all times within the preset time period before each time point and the load rate of the terminal device, an exponential decay model is used to determine the cumulative number of characters at each time point. Combined with the semantic coherence probability value, the encryption delay acceptability at each time point is determined. The specific process is as follows:

[0044] First, in this embodiment, based on the analysis of all characters within a preset time period prior to each moment and the time interval between each character and its preceding character, a semantic continuity analysis algorithm is used to determine the semantic coherence probability value at each moment. This value is used to characterize the probability that the content input by the input method within the preset time period prior to each moment constitutes a complete semantic unit. Specifically:

[0045] In this embodiment, all characters at all times within a preset time period before each time point and the time interval between each character and its preceding character are used as input to the semantic continuity analysis algorithm. The characters at all times are used as hidden state nodes in the state transition probability matrix of the semantic continuity analysis algorithm, and the time interval between each character and its preceding character is used as the weight factor of the corresponding hidden state node in the state transition probability matrix. The likelihood probability at each time point is output as the semantic coherence probability at each time point.

[0046] To further explain, the specific method for constructing the state transition probability matrix in this embodiment is as follows: all characters within a preset time period before each time point are taken as hidden state nodes. For example, "I", "love", and "you" are different states. The frequency of each character appearing together with its next adjacent character within the preset time period before each time point is counted using a historical corpus. For example, the probability of "I" being followed by "love" is counted. A probability matrix is ​​constructed using all characters at all times and their corresponding frequencies as the basic probability matrix. The time interval between each character and its next adjacent character is used as the weight of the probability of each character and multiplied by the probability to obtain a weighted probability matrix, which serves as the state transition probability matrix.

[0047] It should be noted that the preset time period length is set manually. In this embodiment, the preferred time period length is 1 hour. In actual applications, as other implementation methods, implementers can also set it according to specific circumstances. This embodiment does not impose any special restrictions.

[0048] Among them, the semantic continuity analysis algorithm based on Hidden Markov Model (HMM) is a well-known technique, and the specific process of using it to predict semantic continuity will not be elaborated here.

[0049] Based on the semantic coherence probability value at each time point, it can be understood that the semantic coherence probability value reflects the possibility of the contextual coherence of the content entered by the user within a period of time. If the semantic coherence probability value at the current time point is larger, it means that the characters entered by the user within the preset period of time before the current time point are more like a complete and meaningful fragment, such as a phrase or a short sentence, indicating that the possibility of semantic coherence at this time is greater.

[0050] Conversely, the lower the semantic coherence probability value at the current moment, the less likely the characters entered by the user within the preset time period before the current moment are to be a complete and meaningful fragment. They may only be some scattered characters, the middle part of words, repeated input, or the user still hesitating and thinking, indicating that the likelihood of semantic coherence is lower at this time. This situation usually occurs when the user has just started typing, is typing the middle part of a long sentence, or when the typing habits include many pauses and modifications.

[0051] Furthermore, this embodiment uses an exponential decay model to determine the cumulative number of characters at each time point based on the number of unencrypted characters at all times within a preset time period prior to each time point and the load rate of the terminal device. Specifically:

[0052] The number of unencrypted characters and the load rate of the terminal device within the preset time period before each time are used as inputs to the exponential decay model. The number of unencrypted characters within the preset time period before each time is used as the base of the exponential decay model, and the load rate of the terminal device within the preset time period before each time is used as the decay constant of the exponential decay model. The decay value at each time is output as the cumulative number of characters at each time.

[0053] The exponential decay model is a well-known technique, and the specific process of using it to predict decay values ​​will not be elaborated here.

[0054] Based on the cumulative character count at each moment, it can be understood that the cumulative character count quantifies the potential data leakage risk faced by the unencrypted content in the encryption buffer if encryption is delayed. The larger the cumulative character count at the current moment, the stronger the urgency to encrypt immediately. This means that the encryption buffer has accumulated a lot of characters, or the device performance is poor, which may cause encryption to be delayed, making the possibility or time of the unencrypted data being exposed to risk longer.

[0055] Conversely, if the current number of characters is small, it indicates that the user's input speed is slow or that there are not many characters in the encryption buffer. This means that even if encryption is delayed for a short period of time, the number of unencrypted characters in the buffer is relatively small, or the time these characters are exposed to risk is relatively short. Therefore, the urgency of immediate encryption is relatively weak. The system can consider appropriately extending the delay time and waiting for the semantics to become more coherent or for more characters to accumulate before encryption to optimize the user experience.

[0056] Furthermore, this embodiment determines the encryption delay acceptability at each time point based on the cumulative character count and semantic coherence probability value, which characterizes the acceptability of triggering delayed encryption operations at each time point. Specifically:

[0057] As a specific implementation method, in this embodiment, the normalized value of the ratio of semantic coherence probability value to character change rate at each time point is used as the encryption delay acceptance degree at each time point.

[0058] It should be noted that there are many commonly used normalization methods. In this embodiment, the ratio of each time point and all times within the preset time period before that time point is used as the output of the maximum-minimum normalization method. The normalized value of the ratio at each time point is output, thus obtaining the encryption delay acceptance. In practical applications, as other implementation methods, implementers can also choose other normalization methods such as z-score normalization method according to specific circumstances. This embodiment does not impose any special restrictions on the selection of normalization methods.

[0059] Among them, the maximum-minimum normalization method is a well-known technique, and its specific principles will not be elaborated here.

[0060] Based on the encryption delay acceptance at each time point, it can be understood that the encryption delay acceptance reflects the acceptability of allowing delayed encryption operations at the current time. If the semantic coherence probability value is higher at the current time, it means that the current input content is semantically complete, the impact of delayed encryption on user experience is small, and it is safe to wait for a period of time before encryption. Therefore, the corresponding encryption delay acceptance is relatively large. At the same time, if the character accumulation at the current time is smaller, it means that there are not many characters accumulated in the current encryption buffer, and there is no sensitive information accumulated in the current encryption buffer. This means that even if encryption is delayed for a short period of time, the number of unencrypted characters in the buffer is relatively small, or the time these characters are exposed to risk is relatively short. Therefore, the corresponding encryption delay acceptance is relatively large, indicating that the acceptability of allowing delayed encryption operations at the current time is greater.

[0061] Conversely, if the semantic coherence probability value at the current moment is smaller, it indicates that the current input content is not semantically complete. Delayed encryption may interrupt the user's train of thought and affect the accuracy of intelligent prediction. Therefore, the safe waiting time is shorter, and the corresponding encryption delay acceptance is relatively small. At the same time, if the cumulative number of characters at the current moment is larger, it indicates that there are more characters accumulated in the current encryption buffer. This means that delayed encryption will expose more unencrypted characters to risk, or expose them for a longer period of time. Therefore, the corresponding encryption delay acceptance is also relatively small, indicating that the acceptable level of delayed encryption operation at the current moment is lower, and encryption needs to be performed more promptly to ensure data security.

[0062] This application addresses the challenge of balancing user experience and data security in input method encryption. By analyzing real-time user input data, such as character time intervals, the number of unencrypted characters, and device load, and utilizing semantic continuity analysis algorithms and exponential decay models, it calculates the semantic coherence probability value reflecting the integrity of the input content and the cumulative character amount reflecting the potential data leakage risk. Combining these two values, an encryption delay acceptance level is constructed to intelligently determine whether delayed encryption is appropriate. When semantics are coherent and the risk is low, delay is allowed to protect intelligent prediction; when semantics are incoherent or the risk is high, encryption is performed immediately to ensure security. This embodiment can adapt to different user habits and device performance, effectively balancing input fluency and data security without user intervention, thus overcoming the shortcomings of traditional fixed strategies.

[0063] Step S3: Based on the encryption delay acceptance rate at all times within the preset time period before each time, use the exponentially weighted moving average algorithm to obtain the exponential decay weighted value at each time to classify the encryption preference at each time; based on the dispersion of the encryption delay acceptance rate at all times within the preset time period before each time, determine the encryption urgency at each time, and combine the encryption preference classification results at each time to determine the encryption urgency index at each time.

[0064] Due to significant differences in user input habits and dynamic fluctuations in device performance, fixed buffer strategies are difficult to adapt precisely. If the buffer is too large, sensitive characters may be exposed in plaintext in memory for too long. If the buffer is too small, frequent encryption will disrupt semantic continuity and increase performance overhead.

[0065] Therefore, this embodiment further uses an exponentially weighted moving average algorithm to obtain the exponentially decaying weighted value at each time point based on the encryption delay acceptance rate at all times within the preset time period before each time point, in order to classify the encryption preferences at each time point; based on the dispersion of the encryption delay acceptance rate at all times within the preset time period before each time point, the encryption urgency at each time point is determined, and combined with the encryption preference classification results at each time point, the encryption urgency index at each time point is determined to dynamically balance the encryption time. The specific process is as follows:

[0066] In this embodiment, firstly, based on the encryption delay acceptance rates at all times within a preset time period prior to each time point, an exponentially weighted moving average algorithm is used to obtain the exponentially decaying weighted value at each time point, in order to classify the encryption preferences at each time point. Specifically:

[0067] As a specific implementation method, in this embodiment, the encryption delay acceptance rate at all times within a preset time period before each time is used as the input of the exponentially weighted decay average algorithm. The decay coefficient is set to a preset value, the sliding window is set to a preset length, and the exponentially decayed weighted value at any time within the preset time period before each time is output. By traversing all times, the exponentially decayed weighted value at each time is obtained.

[0068] It should be noted that the attenuation coefficient and the size of the sliding window are both set manually. In this embodiment, the value of the attenuation coefficient, i.e. the preset value, is 0.9, and the value of the sliding window size, i.e. the preset length, is 50. In actual application, the implementer can also set them according to the specific situation. This embodiment does not impose any special restrictions.

[0069] The exponentially weighted decaying average algorithm is a well-known technique, and the specific calculation process of the exponentially decaying weighted value at each time point will not be elaborated here.

[0070] Based on the exponential decay weighted value at each time point, it can be understood that the weighted decay index reflects the user's overall tolerance for delayed encryption in the recent period. If the exponential decay weighted value at the current time point is smaller, it indicates that the user's acceptance of encryption delay is generally lower in the recent period. That is, the semantic continuity of the user's recent input content may be poor or the accumulated content in the encryption buffer is large. Therefore, the lower the user's acceptance of delayed encryption at the current time point, the more timely encryption should be performed.

[0071] Conversely, if the exponential decay weighted value is larger at the current moment, it indicates that users generally have a higher tolerance for encryption delays recently. This means that the semantic continuity of the user's recent input content may be better, or the accumulated content in the encryption buffer may be relatively small, resulting in a lower perception of risk. Therefore, the higher the user's tolerance for delayed encryption at the current moment, the longer the waiting time can be extended to wait for a more natural semantic pause before encryption, in order to better ensure the fluency of input and the accuracy of intelligent prediction.

[0072] Furthermore, based on the aforementioned exponentially decaying weighted value, encryption preferences at each time point are classified as follows:

[0073] As a specific implementation method, in this embodiment, the encryption preferences include three types: immediate encryption, normal encryption, and deferred encryption, which are respectively labeled as 2, 1, and 0;

[0074] If the normalized value of the exponentially decaying weighted value at time i is less than the preset first value, then the encryption preference label at time i is set to 2. This indicates that the overall acceptance of encryption delay was low in the period before time i, which means that the semantic continuity of the input content was low in the period before time i, and the accumulation of sensitive information may be large. Therefore, the lower the acceptance of delayed encryption, the more timely encryption is required. A larger label value is set to increase the urgency of encryption at time i in the future.

[0075] If the normalized value of the exponentially decaying weighted value at time i is greater than the preset second value, then the encryption preference label at time i is set to 0. This indicates that the semantic continuity of the input content in the period before time i is good and the accumulation of sensitive information may be small. Therefore, the acceptance of delayed encryption is smaller. Thus, encryption can be delayed, a smaller label value is set, and the encryption level at time i is appropriately reduced.

[0076] If the normalized value of the exponentially decaying weighted value at time i is between the preset first value and the preset second value, then the label of the encryption preference at time i is set to 1. This indicates that the semantic continuity of the input content and the degree of accumulation of sensitive information in the period before time i are relatively moderate. Therefore, the encryption preference at time i is classified as normal encryption and its label value is set to 1. The preset first value is less than the preset second value. The encryption preference classification at any time is obtained by traversing all times.

[0077] It should be noted that the values ​​of the first preset value and the second preset value are both set manually. In this embodiment, the first preset value is 0.3 and the second preset value is 0.7. In actual application, the implementer can also set them according to the specific situation. This embodiment does not impose any special restrictions.

[0078] Furthermore, this embodiment determines the encryption urgency at each time point based on the dispersion of encryption delay acceptance at all times within a preset time period prior to each time point, and determines the encryption urgency index at each time point by combining the encryption preference classification results at each time point, specifically as follows:

[0079] In this embodiment, the coefficient of variation of the encryption delay acceptance rate at all times within the preset time period before each time is used as the encryption urgency at each time, which is used to characterize the urgency of encryption at each time.

[0080] Based on the encryption urgency at each moment, we can understand that encryption urgency measures the degree of need for encryption at each point in time. A higher coefficient of variation in the encryption delay acceptability across all moments within a preset time period prior to the current moment indicates greater instability and unpredictability of the user input stream during that period. Such fluctuations may imply potential risks, thus necessitating encryption consideration more urgently. Conversely, a lower coefficient of variation in the encryption delay acceptability across all moments within a preset time period prior to the current moment indicates relatively stable and predictable user input streams during that period, with minimal changes in user input rhythm or security margin, resulting in relatively low potential risks. Therefore, the urgency for encryption is relatively low, and the system can prioritize ensuring input fluency and semantic continuity, appropriately extending the encryption delay time.

[0081] Furthermore, based on the encryption urgency and the classification preference label, an encryption urgency index is determined at each time point to characterize the urgency of encryption at each time point. The encryption urgency index extraction process provided in this embodiment is illustrated in the diagram below. Figure 2 As shown, the specific process for determining the encryption urgency index is as follows:

[0082] As a specific implementation method, in this embodiment, the encryption urgency index at time i is... The expression is: In the formula, This represents the encryption preference label value at time i; The urgency of encryption at a given time is indicated by ; norm[ ] represents the normalization function.

[0083] Based on the encryption urgency index at each time point, it can be understood that if the encryption urgency at time i is greater, the encryption preference label value is larger, indicating that encryption is more necessary at time i, and therefore the corresponding encryption urgency index is larger; conversely, if the encryption urgency at time i is smaller, the encryption preference label value is smaller, indicating that encryption can be delayed for a period of time at time i to improve the user's input method experience, and therefore the corresponding encryption urgency index is smaller.

[0084] Thus, this embodiment analyzes the user's recent input patterns and security margins, uses an exponentially weighted moving average to determine the user's preference for delayed encryption, and combines the instability of the input stream to assess the urgency of encryption, ultimately obtaining an encryption urgency index to intelligently determine when to encrypt. This method effectively avoids the shortcomings of the fixed buffer strategy and can significantly improve input fluency and user experience while ensuring data security.

[0085] Step S4: Based on the encryption urgency index at the current moment, encrypt and decrypt the text input by the input method at the current moment.

[0086] Due to differences in user input habits and fluctuations in device performance, existing input method encryption and decryption technologies suffer from inaccuracies in dynamically adjusting the buffer trigger timing, potentially leading to a serious data security risk of brief plaintext exposure. Therefore, this embodiment encrypts and decrypts text in the input method based on the encryption urgency obtained in step S3 above, specifically as follows:

[0087] If the current encryption urgency index is greater than the preset urgency threshold, the AES symmetric encryption algorithm will be used immediately to batch encrypt all contents of the encryption buffer. This mechanism prioritizes the security of core data and prevents plaintext from remaining in high-risk or resource-scarce scenarios.

[0088] Conversely, if the encryption urgency index at the current moment is less than or equal to the preset urgency threshold, the AES encryption algorithm is used to encrypt the contents of the encryption buffer when the user inputs punctuation or a newline, in order to maintain input fluency to the greatest extent.

[0089] It should be noted that the preset urgency threshold is set manually. In this embodiment, the preset urgency threshold is set to 0.8. In actual applications, implementers can also set it according to specific circumstances. This embodiment does not impose any special restrictions. The dual-trigger mechanism dynamically balances semantic continuity with the risk of data leakage. When the encryption urgency index is greater than the preset urgency threshold, encryption is forced, which can prevent plaintext exposure caused by sensitive characters lingering in the buffer. This is especially suitable for scenarios where sensitive information such as ID numbers and passwords are entered or where device performance suddenly drops. When the encryption urgency index is less than or equal to the preset urgency threshold, encryption is intelligently delayed until the natural input interval. This preserves the context to support intelligent prediction and avoids frequent encryption that breaks semantics. This strategy significantly reduces the dual risks of traditional fixed buffer schemes, such as premature encryption disrupting input fluency or late encryption causing brief plaintext leakage.

[0090] After the sending end encrypts the contents of the buffer using the AES symmetric encryption algorithm through a forced or intelligent triggering strategy, the ciphertext stream is transmitted to the receiving end in real time. The receiving end's input method identifies the ciphertext packet through its built-in decryption module, calls the same key to perform instant AES decryption, restores it to the original plaintext, and fills it into the receiving end's input box. The decryption operation is completed in milliseconds before the receiving end's input method renders the data. The user only sees plaintext interaction, while the actual transmission and buffering are all ciphertext.

[0091] The AES symmetric encryption algorithm and AES decryption are well-known technologies, and the specific process of encrypting and decrypting input characters using them will not be elaborated here.

[0092] Thus, this embodiment dynamically calculates the encryption urgency index by analyzing user input patterns, device performance, and semantic continuity in real time, and adaptively determines when to encrypt. When the risk is high or the semantics are incoherent, encryption is performed immediately to ensure security, while when the risk is low and the semantics are coherent, encryption is delayed until the natural pause point to maintain fluency. This method effectively solves the drawbacks of the fixed buffer strategy and achieves the best balance between data security and input experience without user intervention, significantly improving the level of privacy protection and optimizing input fluency.

[0093] Based on the same inventive concept as the above methods, embodiments of this application also provide a fast text encryption and decryption system for an input method, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of any one of the above-described fast text encryption and decryption methods for an input method.

[0094] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments of this specification have been described above. Additionally, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some implementations, multitasking and parallel processing are possible or may be advantageous.

[0095] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0096] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.

Claims

1. A method for fast text encryption and decryption in input methods, characterized in that, The method includes the following steps: During the editing process on the terminal device, the system can obtain in real time the characters the user types on the input method keyboard, the load rate of the terminal device, and the number of unencrypted characters in the encrypted buffer of the input method keyboard, as well as the time interval between each character and its predecessor. Based on the analysis of all characters at all times within the preset time period before each time point and the time interval between each character and its previous character, a semantic continuity analysis algorithm is used to determine the semantic coherence probability value at each time point; based on the number of unencrypted characters at all times within the preset time period before each time point and the load rate of the terminal device, an exponential decay model is used to determine the cumulative number of characters at each time point, and combined with the semantic coherence probability value, the encryption delay acceptance rate at each time point is determined. Based on the encryption delay acceptance rate at all times within the preset time period before each time, the exponentially weighted moving average algorithm is used to obtain the exponential decay weighted value at each time to classify encryption preferences at each time. Based on the dispersion of encryption delay acceptance rate at all times within the preset time period before each time, the encryption urgency at each time is determined. Combined with the encryption preference classification results at each time, the encryption urgency index at each time is determined. If the current encryption urgency index is greater than the preset urgency threshold, the AES symmetric encryption algorithm is immediately used to batch encrypt all contents of the encryption buffer. Otherwise, the AES encryption algorithm is used to encrypt the contents of the encryption buffer when the user inputs punctuation or a newline.

2. The text fast encryption / decryption method for input methods as described in claim 1, characterized in that, The method for determining the semantic coherence probability value at each time point is as follows: The input of the semantic continuity analysis algorithm is to take all characters at all times within the preset time period before each time and the time interval between each character and its predecessor. The characters at all times are used as hidden state nodes in the state transition probability matrix of the semantic continuity analysis algorithm, and the time interval between each character and its predecessor is used as the weight factor of the hidden state node in the state transition probability matrix. The likelihood probability at each time is output as the semantic coherence probability at each time.

3. The text fast encryption / decryption method for input methods as described in claim 1, characterized in that, The method for determining the cumulative character amount at each time point is as follows: The number of unencrypted characters and the load rate of the terminal device within the preset time period before each time are used as inputs to the exponential decay model. The number of unencrypted characters within the preset time period before each time is used as the base of the exponential decay model, and the load rate of the terminal device within the preset time period before each time is used as the decay constant of the exponential decay model. The decay value at each time is output as the cumulative number of characters at each time.

4. The text fast encryption / decryption method for input methods as described in claim 1, characterized in that, The encryption delay acceptance at each time point is the normalized value of the ratio of the semantic coherence probability value to the character change rate at each time point.

5. The method for fast text encryption and decryption for input methods as described in claim 1, characterized in that, The method for obtaining the exponentially decaying weighted values ​​at each time point is as follows: The encryption delay acceptance rate at all times within a preset time period before each time is used as the input of the exponentially weighted decay average algorithm. The decay coefficient is set to a preset value, the sliding window is set to a preset length, and the exponentially decayed weighted value at any time within the preset time period before each time is output. By traversing all times, the exponentially decayed weighted value at each time is obtained.

6. The method for fast text encryption and decryption for input methods as described in claim 1, characterized in that, The classification of encryption preferences at each time point includes: Encryption preferences include three types: instant encryption, normal encryption, and deferred encryption, with labels set to 2, 1, and 0 respectively. If the normalized value of the exponentially decaying weighted value at time i is less than the preset first value, then the label of the encryption preference at time i is set to 2. If the normalized value of the exponentially decaying weighted value at time i is greater than the preset second value, then the label of the encryption preference at time i is set to 0. If the normalized value of the exponentially decaying weighted value at time i is between a preset first value and a preset second value, then the label of the encryption preference at time i is set to 1, where the preset first value is less than the preset second value; traverse all times to obtain the encryption preference classification at any time.

7. The text fast encryption / decryption method for input methods as described in claim 1, characterized in that, The encryption urgency at each time point is the coefficient of variation of the encryption delay acceptance at all times within a preset time period prior to each time point.

8. The method for fast text encryption and decryption for input methods as described in claim 6, characterized in that, The expression for the encryption urgency index at each time point is: In the formula, This represents the encryption urgency index at time i; This represents the encryption preference label value at time i; The urgency of encryption at a given time is indicated by ; norm[ ] represents the normalization function.

9. A text fast encryption / decryption system for an input method, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the fast text encryption / decryption method for an input method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Data collection and analysis method

    CN117290884A

  • Severe care data management system based on block chain

    CN120376021A