Quick character encryption and decryption method and system for input method

By analyzing user input and device status in real time, using semantic continuity and exponential decay models to calculate the encryption urgency index, and dynamically adjusting the encryption timing, the problem of balancing user experience and security in input method encryption technology is solved, and the privacy protection and fluency of the input method are improved.

CN120632918AActive Publication Date: 2025-09-12国投云网数字科技有限公司 +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511127842.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-13
Publication Date
2025-09-12
Estimated Expiration
2045-08-13

AI Technical Summary

Technical Problem

Existing input method encryption technology has difficulties in balancing user experience and data security. The fixed buffer strategy is difficult to adapt to user habits and device performance differences, resulting in encryption response delays or misjudgments, affecting input fluency and privacy protection levels.

Method used

By obtaining the characters input by the user, the device load rate and the number of unencrypted characters in the buffer in real time, the encryption delay acceptance is calculated using semantic continuity analysis and the exponential decay model, and the encryption urgency index is determined by combining the exponentially weighted moving average algorithm to dynamically decide when to perform encryption.

Benefits of technology

It implements adaptive encryption decisions based on different user habits and device performance, balances input fluency and data security, avoids the shortcomings of traditional strategies, and improves privacy protection and input experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120632918A_ABST
    Figure CN120632918A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data security, in particular to a rapid character encryption and decryption method and system for an input method, and the method comprises the steps: obtaining an exponential decay weighted value at each moment through employing an exponential weighted moving average algorithm based on the encryption delay acceptability at all moments within a preset time period before each moment, the encryption preference at each moment is classified; and determining an encryption urgency index at each moment based on the dispersion degree of the encryption delay acceptability at all moments within a preset time period before each moment in combination with an encryption preference classification result at each moment, and encrypting characters of the input method at the current moment. According to the method and the device, the defect that a fixed buffer strategy affects balanced dynamic encryption is overcome, and the privacy protection level and the input fluency of the input method are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data security technology, and in particular to a method and system for rapid text encryption and decryption for input methods. Background Art

[0002] With the widespread use of mobile internet and the frequent occurrence of privacy breaches, input methods, as the core entry point for text input, are facing an increasingly prominent risk of transmitting plaintext content. Traditional encryption mechanisms are often accompanied by complex operations and performance loss, which undermines the immediacy and smoothness of the input experience. Therefore, rapid text encryption and decryption technology has emerged. It aims to achieve localized or low-latency encryption of characters within the input box at the moment of keystroke, transmit the ciphertext to the receiving end, and then seamlessly decrypt and restore it. This allows for seamless protection of sensitive information such as account passwords, ID numbers, and medical records entered in scenarios such as chat, email, and finance, without interrupting the input flow or changing operating habits. This significantly improves privacy and security, enhances the public's sense of security in the digital space, and helps build a more reliable communication ecosystem.

[0003] There are two main approaches to fast encryption in input methods: word-by-word encryption, while secure, undermines semantics, impacts intelligent prediction, and is vulnerable to attack. Word buffer encryption, while preserving context, makes it difficult to determine when encryption is triggered, and differences in user habits and device performance can lead to the risk of plaintext exposure. Existing technologies primarily address the flaws of partial buffer encryption through dynamic context-aware buffers. However, the dynamic buffer size adjustment algorithm relies heavily on user behavior modeling and real-time calculations. Due to differences in user typing habits and low-performance devices, encryption response delays or misjudgments can occur, reducing the privacy protection and smoothness of input methods. Summary of the Invention

[0004] In order to solve the above technical problems, the purpose of this application is to provide a method and system for fast text encryption and decryption for input methods. The technical solutions adopted are as follows: In a first aspect, an embodiment of the present application provides a method for fast text encryption and decryption for an input method, the method comprising the following steps: During the editing process of the terminal device, the user obtains in real time the characters typed by the user on the input method keyboard, the load rate of the terminal device, the number of unencrypted characters in the encryption buffer of the input method keyboard, and the time interval between each character and the previous character; Based on analyzing all characters at a preset time period before each moment and the time intervals between all characters and their previous characters, a semantic continuity analysis algorithm is used to determine a semantic coherence probability value at each moment; based on the number of unencrypted characters at all moments in the preset time period before each moment and the load rate of the terminal device, an exponential decay model is used to determine the cumulative amount of characters at each moment, and combined with the semantic coherence probability value, the encryption delay acceptance at each moment is determined; Based on the acceptance of encryption delay at all times within a preset period before each moment, an exponentially weighted moving average algorithm is used to obtain an exponential decay weighted value at each moment to classify the encryption preference at each moment. Based on the degree of dispersion of the acceptance of encryption delay at all times within the preset period before each moment, the encryption urgency at each moment is determined, and combined with the encryption preference classification results at each moment, the encryption urgency index at each moment is determined. Based on the encryption urgency index at the current moment, the text of the input method at the current moment is encrypted.

[0005] Preferably, the method for determining the semantic coherence probability value at each moment is: The characters at all moments within a preset time period before each moment and the time intervals between all characters and their previous characters are used as inputs to the semantic continuity analysis algorithm, wherein the characters at all moments are used as hidden state nodes of the state transition probability matrix in the semantic continuity analysis algorithm, and the time intervals between all characters and their previous characters are used as weight factors of the hidden state nodes in the state transition probability matrix, and the likelihood probability at each moment is output as the semantic coherence probability at each moment.

[0006] Preferably, the method for determining the cumulative amount of characters at each moment is: The number of unencrypted characters at all times within the preset time period before each moment and the load rate of the terminal device are used as inputs of the exponential decay model, wherein the number of unencrypted characters at all times within the preset time period before each moment is used as the base of the exponential decay model, and the load rate of the terminal device at all times within the preset time period before each moment is used as the decay constant of the exponential decay model, and the attenuation value at each moment is output as the accumulated amount of characters at each moment.

[0007] Preferably, the encryption delay acceptance at each moment is a normalized value of the ratio of the semantic coherence probability value to the character change rate at each moment.

[0008] Preferably, the method for obtaining the exponential decay weighted value at each moment is: The encryption delay acceptance at all moments in the preset period before each moment is used as the input of the exponentially weighted decay averaging algorithm, where the decay coefficient is set to a preset value and the sliding window is set to a preset length. The exponential decay weighted value at any moment in the preset period before each moment is output, and all moments are traversed to obtain the exponential decay weighted value at each moment.

[0009] Preferably, the classifying the encryption preferences at each moment includes: Encryption preferences include immediate encryption, normal encryption, and suspended encryption, with labels set to 2, 1, and 0 respectively; If the normalized value of the exponential decay weighted value at time i is less than the preset first value, the encryption preference label at time i is set to 2; If the normalized value of the exponential decay weighted value at time i is greater than the preset second value, the encryption preference label at time i is set to 0; If the normalized value of the exponential decay weighted value at time i is between a preset first value and a preset second value, 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 moments to obtain the encryption preference classification at any moment.

[0010] Preferably, the encryption urgency at each moment is the coefficient of variation of the encryption delay acceptance at all moments in a preset period before each moment.

[0011] Preferably, the expression of the encryption urgency index at each moment is: Where, represents the encryption urgency index at time i; represents the encryption preference tag value at time i; represents the encryption urgency at the moment; norm[ ] represents the normalization function.

[0012] Preferably, the encrypting of the text in the input method at the current moment includes: If the encryption urgency index at the current moment 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 enters punctuation or line breaks.

[0013] In the second aspect, an embodiment of the present application also provides a system for rapid encryption and decryption of text for an input method, comprising 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-mentioned methods for rapid encryption and decryption of text for an input method.

[0014] This application has at least the following beneficial effects: This application addresses the difficult problem of balancing user experience and data security in input method encryption. By analyzing the real-time data of user input, namely: character time interval, number of unencrypted characters, and device load, and using the semantic continuity analysis algorithm and exponential decay model, the semantic coherence probability value that can reflect the integrity of the input content and the cumulative amount of characters that reflect the potential risk of data leakage are calculated respectively. Then, combining these two values, an encryption delay acceptance is constructed to intelligently determine whether delayed encryption is currently suitable, thereby adapting to different user habits and device performance, effectively balancing input fluency and data security without user intervention, and solving the problems of traditional fixed encryption. Furthermore, this application analyzes the user's recent input pattern and security margin, uses an exponentially weighted moving average to determine the user's preference for delayed encryption, and combines the instability of the input stream to evaluate the urgency of encryption, and finally obtains an encryption urgency index, which adaptively decides when to encrypt. When the risk is high or the semantics are incoherent, encryption is immediately performed to ensure security. When the risk is low and the semantics are coherent, encryption is delayed to a natural pause point to maintain smoothness. This effectively solves the drawbacks of the fixed buffer strategy, achieves the best balance between data security and input experience without user intervention, and improves the privacy protection level and input fluency of the input method. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions and advantages of the embodiments of the present application or the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0016] Figure 1 A flowchart of a method for rapid text encryption and decryption for an input method provided in one embodiment of the present application; Figure 2 A schematic diagram of the encrypted urgency index extraction process provided in one embodiment of the present application. DETAILED DESCRIPTION

[0017] To further illustrate the technical means and effects employed by this application to achieve the intended invention objectives, the following, in conjunction with the accompanying drawings and preferred embodiments, describes in detail the specific implementation, structure, features, and effects of the method and system for rapid text encryption and decryption for an input method proposed in this application. In the following description, different references to "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.

[0018] Unless defined otherwise, 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 belongs.

[0019] The specific scheme of the method and system for rapid text encryption and decryption for input method provided by this application is described in detail below with reference to the accompanying drawings.

[0020] See also Figure 1 , which shows a flowchart of a method for fast encryption and decryption of text for an input method provided by an embodiment of the present application, the method comprising the following steps: Step S1: During the editing process of the terminal device, the characters typed by the user on the input method keyboard, the load rate of the terminal device, and the number of unencrypted characters in the encryption buffer of the input method keyboard are obtained in real time, and the time interval between each character and the previous character is obtained.

[0021] A keystroke monitoring sensor is installed in the keyboard event driver layer of the input method framework to obtain the characters typed by the user on the input method keyboard in real time during the editing process of the terminal device, and to obtain the time interval between each character and the previous character; in particular, if no key is pressed continuously, the captured character is set to a null value, and when the next keystroke occurs, the time interval between the next keystroke and the most recent keystroke before it is obtained for subsequent analysis.

[0022] 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.

[0023] Install a CPU monitor at the device hardware layer to collect real-time CPU load rate for dynamic evaluation of system resource support for encryption operations.

[0024] It should be noted that the acquisition frequency of all the above sensors is set to f, and the acquisition of all the above data is synchronous and real-time, wherein the value of the acquisition frequency f is set manually. In this embodiment, the value of the acquisition frequency f is 20 Hz. In actual application, as other implementation methods, the implementer can also set it by himself according to the specific situation. This embodiment does not impose any special restrictions.

[0025] Step S2: Based on analyzing the characters at all moments in the preset time period before each moment and the time intervals between all characters and their previous characters, a semantic continuity analysis algorithm is used to determine the semantic coherence probability value at each moment; based on the number of unencrypted characters at all moments in the preset time period before each moment and the load rate of the terminal device, an exponential decay model is used to determine the cumulative amount of characters at each moment, and combined with the semantic coherence probability value, the encryption delay acceptance at each moment is determined.

[0026] Due to the high diversity of user input habits and significant fluctuations in terminal device performance, traditional fixed buffers or simple trigger mechanisms face core difficulties in input method text fast encryption systems. It is difficult to accurately determine the actual encryption. Encryption too early will split the semantics and destroy the intelligent prediction function; encryption too late will cause sensitive characters in the buffer to be exposed in plain text for too long, significantly increasing data security risks and making them easy to be snooped or intercepted by malicious processes, causing serious data security incidents.

[0027] Therefore, in order to find an appropriate encryption time to balance user experience and data security, this embodiment uses a semantic continuity analysis algorithm to determine the semantic coherence probability value at each moment based on analyzing all characters at all moments in a preset period before each moment, as well as the time intervals between all characters and their previous characters. Based on the number of unencrypted characters at all moments in the preset period before each moment and the load rate of the terminal device, an exponential decay model is used to determine the cumulative amount of characters at each moment. Combined with the semantic coherence probability value, the encryption delay acceptance at each moment is determined. The specific process is as follows: First, in this embodiment, based on analyzing the characters at all times within a preset period before each moment and the time intervals between all characters and their previous characters, a semantic continuity analysis algorithm is used to determine the semantic coherence probability value at each moment. This value is used to represent the likelihood that the content input by the input method within the preset period before each moment constitutes a complete semantic unit. Specifically, the value is: In this embodiment, the characters at all moments within a preset time period before each moment and the time intervals between all characters and their previous characters are used as inputs to the semantic continuity analysis algorithm, wherein the characters at all moments are used as hidden state nodes of the state transition probability matrix in the semantic continuity analysis algorithm, and the time intervals between all characters and their previous characters are used as weight factors of the corresponding hidden state nodes in the state transition probability matrix, and the likelihood probability at each moment is output as the semantic coherence probability at each moment.

[0028] It should be noted that the specific method for constructing the state transition probability matrix in this embodiment is: taking the characters at all moments in the preset time period before each moment as hidden state nodes, for example: "I", "love", "you", etc. are all different states, and using the historical corpus to count the frequency of each character and its adjacent next character appearing together in the preset time period before each moment, for example, counting the probability of "I" being followed by "love", and constructing a probability matrix of the characters at all moments and the corresponding frequencies as the basic probability matrix, and taking the time interval between each character and its adjacent next character as the weight of the probability of each character and multiplying it with the probability to obtain a weighted probability matrix as the state transition probability matrix.

[0029] It should be noted that the value of the preset time period length is set manually. In this embodiment, the value of the better time period length is 1 hour. In actual application, as other implementation methods, the implementer can also set it by himself based on the specific situation. This embodiment does not impose any special restrictions.

[0030] Among them, the semantic continuity analysis algorithm based on the Hidden Markov Model (HMM) is a well-known technology, and the specific process of using it to predict semantic continuity will not be described in detail.

[0031] The semantic coherence probability values ​​at each moment reflect the likelihood of contextual coherence of the content input by the user over a period of time. A larger semantic coherence probability value at the current moment indicates that the characters input by the user during the preset period before the current moment are more likely to be a complete and meaningful segment, such as a phrase or a short sentence, indicating a greater likelihood of semantic coherence. Conversely, if the semantic coherence probability at the current moment is lower, it means that the characters entered by the user in the preset period before the current moment are less likely to be complete and meaningful. They may be just scattered characters, the middle of a word, repeated input, or the user is still hesitating and thinking, indicating that the probability of semantic coherence is lower at this time. This situation usually occurs when the user is just starting to type, is in the middle of a long sentence, or has a typing habit that includes frequent pauses and revisions.

[0032] Furthermore, this embodiment uses an exponential decay model to determine the cumulative amount of characters at each moment based on the number of unencrypted characters at all moments in a preset period before each moment and the load rate of the terminal device, specifically: The number of unencrypted characters at all times within the preset time period before each moment and the load rate of the terminal device are used as inputs of the exponential decay model, wherein the number of unencrypted characters at all times within the preset time period before each moment is used as the base of the exponential decay model, and the load rate of the terminal device at all times within the preset time period before each moment is used as the decay constant of the exponential decay model, and the attenuation value at each moment is output as the accumulated amount of characters at each moment.

[0033] The exponential decay model is a well-known technology, and the specific process of using it to predict the decay value will not be described in detail.

[0034] The accumulated character count at each moment quantifies the potential data leakage risk faced by unencrypted content in the encryption buffer if encryption is delayed. The greater the accumulated character count at the current moment, the greater the urgency of encryption. This means that the encryption buffer has accumulated more characters, or that poor device performance may cause encryption to be delayed, making it more likely that the encrypted data will be exposed to risk or for a longer period of time. On the contrary, if the accumulated amount of characters at the current moment is smaller, it means that the user's current input speed is slower, or there are not many characters accumulated in the encryption buffer. This means that even if the 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, waiting for more semantics to be coherent or accumulating more characters before encryption, so as to optimize the user experience.

[0035] Furthermore, this embodiment determines the encryption delay acceptance at each time point based on the cumulative number of characters and the semantic coherence probability value at each time point, which is used to indicate the acceptability of triggering the delayed encryption operation at each time point. Specifically, As a specific implementation, in this embodiment, the normalized value of the ratio of the semantic coherence probability value to the character change rate at each moment is used as the encryption delay acceptance at each moment.

[0036] It should be noted that there are many commonly used normalization methods. In this embodiment, the ratio of each moment and all moments within a preset time period before it is used as the output of the maximum and minimum normalization method, and the normalized value of the ratio at each moment is output, that is, the encryption delay acceptance is obtained. In actual application, as other implementation methods, implementers can also choose other normalization methods such as the z-score normalization method based on specific circumstances. Regarding the selection of normalization methods, this embodiment does not impose any special restrictions.

[0037] Among them, the maximum and minimum value normalization method is a well-known technology, and its specific principle will not be repeated here.

[0038] Based on the encryption delay acceptance at each moment, it can be understood that encryption delay acceptance reflects the degree of acceptability of allowing delayed encryption operations at the current moment. If the semantic coherence probability value at the current moment is larger, it means that the current input content is semantically complete, the impact of delayed encryption on the user experience is small, and it is safe to wait for a while before encryption. Therefore, the corresponding encryption delay acceptance is relatively large. At the same time, if the character accumulation at the current moment 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 degree of acceptability of allowing delayed encryption operations at the current moment is greater. On the contrary, if the semantic coherence probability value at the current moment is smaller, it means that the current input content is not semantically complete, and delayed encryption may interrupt the user's thinking 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 amount of characters at the current moment is larger, it means that there are more characters accumulated in the current encryption buffer, which means that delayed encryption will expose more unencrypted characters to risks, or the exposure time will be longer. Therefore, the corresponding encryption delay acceptance is also relatively small, indicating that the acceptance of delayed encryption operations at the current moment is lower, and encryption needs to be performed more promptly to ensure data security.

[0039] So far, this application addresses the difficult problem of balancing user experience and data security in input method encryption. By analyzing real-time data of user input, such as: character time interval, number of unencrypted characters, and device load, and using semantic continuity analysis algorithm and exponential decay model, the semantic coherence probability value that can reflect the integrity of the input content and the cumulative amount of characters that reflect the potential data leakage risk are calculated respectively. Then, combining these two values, an encryption delay acceptance is constructed to intelligently determine whether delayed encryption is currently suitable. When the semantics are coherent and the risk is low, delay is allowed to protect intelligent prediction; when the 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, and effectively balances input fluency and data security without user intervention, solving the shortcomings of traditional fixed strategies.

[0040] Step S3: Based on the acceptance of encryption delay at all moments in the preset time period before each moment, an exponentially weighted moving average algorithm is used to obtain an exponential decay weighted value at each moment to classify the encryption preference at each moment; based on the discrete degree of the acceptance of encryption delay at all moments in the preset time period before each moment, the encryption urgency at each moment is determined, and combined with the encryption preference classification results at each moment, the encryption urgency index at each moment is determined.

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

[0042] Therefore, this embodiment further uses an exponentially weighted moving average algorithm to obtain an exponential decay weighted value at each moment based on the encryption delay acceptance at all moments in a preset period before each moment, so as to classify the encryption preference at each moment. The encryption urgency at each moment is determined based on the degree of dispersion of the encryption delay acceptance at all moments in the preset period before each moment, and the encryption urgency index at each moment is determined in combination with the encryption preference classification results at each moment, so as to dynamically balance the encryption moments. The specific process is as follows: In this embodiment, first, based on the encryption delay acceptance at all times within a preset period before each time, an exponentially weighted moving average algorithm is used to obtain an exponential decay weighted value at each time, so as to classify the encryption preference at each time. Specifically, As a specific implementation method, in this embodiment, the encryption delay acceptance at all moments in a preset time period before each moment is used as the input of an exponentially weighted decay averaging algorithm, wherein the decay coefficient is set to a preset value, the sliding window is set to a preset length, and the exponential decay weighted value at any moment in the preset time period before each moment is output, and all moments are traversed to obtain the exponential decay weighted value at each moment.

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

[0044] The exponentially weighted decay averaging algorithm is a well-known technology, and the specific calculation process of the exponential decay weighted value at each moment using it will not be described in detail.

[0045] The exponential decay weighted values ​​at each moment indicate that the weighted decay exponent reflects the user's overall tolerance for delayed encryption in the recent period. A smaller exponential decay weighted value indicates a generally lower user acceptance of encryption delays. This suggests that the semantic continuity of the user's recent input may be poor or the encryption buffer may have a large amount of accumulated content. Therefore, the lower the user's acceptance of delayed encryption at the current moment, the more timely encryption should be performed. On the contrary, if the exponential decay weighted value at the current moment is larger, it means that the user's recent acceptance of encryption delay is generally higher, that is, the semantic continuity of the user's recent input content may be better, or the accumulated content in the encryption buffer is relatively small, and the perception of risk is lower. Therefore, the higher the user's acceptance of delayed encryption at the current moment, the waiting time can be appropriately extended to wait for a more natural semantic pause point before encryption, so as to better ensure the fluency of input and the accuracy of intelligent prediction.

[0046] Furthermore, based on the exponential decay weighted value, the encryption preference at each moment is classified as follows: As a specific implementation, in this embodiment, the encryption preference includes three types: immediate encryption, normal encryption, and suspended encryption, and the labels are set to 2, 1, and 0 respectively; If the normalized value of the exponential decay weighted value at time i is less than a preset first value, the encryption preference label at time i is set to 2, indicating that the overall acceptance of encryption delay in the period before time i is low. This indicates that the semantic continuity of the input content in the period before time i is low, and the accumulation of sensitive information may be large. Therefore, the lower the acceptance of delayed encryption, the more timely encryption is needed, and a larger label value is set to increase the urgency of encryption at time i in the future. If the normalized value of the exponential decay weighted value at time i is greater than the preset second value, 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 is likely to be small. Therefore, the acceptance of delayed encryption is smaller. Therefore, encryption can be delayed, a smaller label value can be set, and the encryption level at time i can be appropriately reduced. If the normalized value of the exponential decay weighted value at moment i is between the preset first value and the preset second value, the label of the encryption preference at moment i is set to 1, indicating that the semantic continuity and the accumulation of sensitive information of the input content in the period before moment i are relatively moderate. Therefore, the encryption preference at moment i is classified as normal encryption, and its label value is set to 1, where the preset first value is less than the preset second value. All moments are traversed to obtain the encryption preference classification at any moment.

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

[0048] Furthermore, this embodiment determines the encryption urgency at each moment based on the discrete degree of encryption delay acceptance at all moments within a preset period before each moment, and determines the encryption urgency index at each moment in combination with the encryption preference classification result at each moment, specifically: In this embodiment, the coefficient of variation of the encryption delay acceptance at all moments in a preset period before each moment is used as the encryption urgency at each moment, to represent the urgency of encryption at each moment.

[0049] The encryption urgency at each moment can be understood as measuring the urgency of encryption at each moment. A larger coefficient of variation in the encryption delay acceptance across all moments in the preset period before the current moment indicates a higher instability and unpredictability of the user input flow during that period. This fluctuation may represent a potential risk, and therefore, the need for encryption becomes more urgent. Conversely, a smaller coefficient of variation in the encryption delay acceptance across all moments in the preset period before the current moment indicates a relatively stable and predictable user input flow during that period, with minimal changes in the user input rhythm or safety margin, indicating a relatively low potential risk. Therefore, the encryption urgency is relatively low, and the system can prioritize input fluency and semantic continuity, appropriately extending the encryption delay.

[0050] Furthermore, based on the encryption urgency and the classification preference label, an encryption urgency index at each moment is determined to characterize the urgency of encryption at each moment. The encryption urgency index extraction process provided in this embodiment is shown in FIG. Figure 2 As shown in Figure 2, the specific process of determining the encryption urgency index is as follows: As a specific implementation, in this embodiment, the encryption urgency index at time i is The expression is: Where, represents the encryption preference tag value at time i; represents the encryption urgency at the moment; norm[ ] represents the normalization function.

[0051] According to the encryption urgency index at each moment, it can be understood that if the encryption urgency at moment i is greater, the encryption preference label value is greater, which means that encryption is needed in a timely manner at moment i, and therefore, the corresponding encryption urgency index is greater; conversely, if the encryption urgency at moment i is smaller, the encryption preference label value is smaller, which means that encryption can be delayed for a period of time at moment i to improve the user experience of the input method, and therefore, the corresponding encryption urgency index is smaller.

[0052] Thus, this embodiment analyzes the user's recent input pattern and security margin, uses an exponentially weighted moving average to determine the user's preference for delayed encryption, and combines the instability of the input stream to evaluate the urgency of encryption. Ultimately, an encryption urgency index is obtained to intelligently decide 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.

[0053] Step S4: Encrypt and decrypt the text in the input method at the current moment based on the encryption urgency index at the current moment.

[0054] Due to differences in user input habits and fluctuations in device performance, existing input method encryption and decryption technologies have inaccuracies when dynamically adjusting the buffer trigger timing, potentially resulting in a serious data security risk of temporary plaintext exposure. Therefore, this embodiment encrypts and decrypts the text of the input method based on the encryption urgency obtained in step S3 above, specifically as follows: If the encryption urgency index at the current moment is greater than the preset urgency threshold, the AES symmetric encryption algorithm will be immediately used to batch encrypt all contents of the encryption buffer. This mechanism prioritizes the security of core data and prevents the retention of plaintext in high-risk or resource-scarce scenarios.

[0055] On the contrary, 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 enters punctuation or line breaks to maintain input fluency to the greatest extent.

[0056] It should be noted that the value of the preset urgency threshold is manually set. In this embodiment, the value of the preset urgency threshold is 0.8. In actual application, the implementer can also set it according to the specific situation. This embodiment does not impose any special restrictions. The dual trigger mechanism dynamically balances semantic continuity and data leakage risk. When the encryption urgency index is greater than the preset urgency threshold, encryption is forced to be performed. This can prevent the exposure of plaintext caused by sensitive characters remaining in the buffer. It is especially suitable for inputting sensitive information such as ID numbers and passwords or in scenarios where device performance drops suddenly. When the encryption urgency index is less than or equal to the preset urgency threshold, encryption is intelligently delayed to the natural input gap, which not only retains the context to support intelligent prediction, but also avoids frequent encryption that splits semantics. This strategy significantly reduces the dual risks of the traditional fixed buffer solution, which destroys input fluency due to premature encryption or causes short-term plaintext leakage due to late encryption.

[0057] After the sender completes the AES symmetric encryption algorithm to encrypt the buffer content through a mandatory or intelligent trigger strategy, the ciphertext stream is transmitted to the receiver in real time. The input method on the receiving end identifies the ciphertext package through the built-in decryption module, calls the same key for immediate AES decryption, restores it to the original plaintext and fills it into the receiver's input box. The decryption operation is completed in milliseconds before the input method on the receiving end renders. The user only sees plaintext interaction, while the actual transmission and cache are all ciphertext.

[0058] Among them, the AES symmetric encryption algorithm and AES decryption are both well-known technologies, and the specific process of using them to encrypt and decrypt input characters will not be described in detail.

[0059] To this end, this embodiment dynamically calculates the encryption urgency index by real-time analysis of user input patterns, device performance, and semantic continuity, and adaptively decides 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 to a natural pause point to maintain smoothness. This method effectively solves the drawbacks of the fixed buffer strategy, achieves the best balance between data security and input experience without user intervention, significantly improves the level of privacy protection, and optimizes input fluency.

[0060] Based on the same inventive concept as the above method, an embodiment of the present application also provides a system for rapid text encryption and decryption for 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, the steps of any one of the above-mentioned methods for rapid text encryption and decryption for input method are implemented.

[0061] It should be noted that the order in which the embodiments of the present application are presented is for illustrative purposes only and does not necessarily represent the superiority or inferiority of the embodiments. Furthermore, the foregoing descriptions of specific embodiments of this specification are provided. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential sequence shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

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

[0063] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A method for fast encryption and decryption of text for input method, characterized in that: The method comprises the following steps: During the editing process of the terminal device, the user obtains in real time the characters typed by the user on the input method keyboard, the load rate of the terminal device, the number of unencrypted characters in the encryption buffer of the input method keyboard, and the time interval between each character and the previous character; Based on analyzing all characters at a preset time period before each moment and the time intervals between all characters and their previous characters, a semantic continuity analysis algorithm is used to determine a semantic coherence probability value at each moment; based on the number of unencrypted characters at all moments in the preset time period before each moment and the load rate of the terminal device, an exponential decay model is used to determine the cumulative amount of characters at each moment, and combined with the semantic coherence probability value, the encryption delay acceptance at each moment is determined; Based on the acceptance of encryption delay at all times within a preset period before each moment, an exponentially weighted moving average algorithm is used to obtain an exponential decay weighted value at each moment to classify the encryption preference at each moment. Based on the degree of dispersion of the acceptance of encryption delay at all times within the preset period before each moment, the encryption urgency at each moment is determined, and combined with the encryption preference classification results at each moment, the encryption urgency index at each moment is determined. Based on the encryption urgency index at the current moment, the text of the input method at the current moment is encrypted.

2. The method for rapid encryption and decryption of text for input method according to claim 1, wherein: The method for determining the semantic coherence probability value at each moment is: The characters at all moments within a preset time period before each moment and the time intervals between all characters and their previous characters are used as inputs to the semantic continuity analysis algorithm, wherein the characters at all moments are used as hidden state nodes of the state transition probability matrix in the semantic continuity analysis algorithm, and the time intervals between all characters and their previous characters are used as weight factors of the hidden state nodes in the state transition probability matrix, and the likelihood probability at each moment is output as the semantic coherence probability at each moment.

3. The method for rapid encryption and decryption of text for input method according to claim 1, wherein: The method for determining the cumulative amount of characters at each moment is: The number of unencrypted characters at all times within the preset time period before each moment and the load rate of the terminal device are used as inputs of the exponential decay model, wherein the number of unencrypted characters at all times within the preset time period before each moment is used as the base of the exponential decay model, and the load rate of the terminal device at all times within the preset time period before each moment is used as the decay constant of the exponential decay model, and the attenuation value at each moment is output as the accumulated amount of characters at each moment.

4. The method for rapid encryption and decryption of text for input method according to claim 1, wherein: The encryption delay acceptance at each moment is a normalized value of the ratio of the semantic coherence probability value to the character change rate at each moment.

5. The method for rapid encryption and decryption of text for input method according to claim 1, wherein: The method for obtaining the exponential decay weighted value at each moment is: The encryption delay acceptance at all moments in the preset period before each moment is used as the input of the exponentially weighted decay averaging algorithm, where the decay coefficient is set to a preset value and the sliding window is set to a preset length. The exponential decay weighted value at any moment in the preset period before each moment is output, and all moments are traversed to obtain the exponential decay weighted value at each moment.

6. The method for rapid encryption and decryption of text for input method according to claim 1, wherein: The classification of encryption preferences at each moment includes: Encryption preferences include immediate encryption, normal encryption, and suspended encryption, with labels set to 2, 1, and 0 respectively; If the normalized value of the exponential decay weighted value at time i is less than the preset first value, the encryption preference label at time i is set to 2; If the normalized value of the exponential decay weighted value at time i is greater than the preset second value, the encryption preference label at time i is set to 0; If the normalized value of the exponential decay weighted value at time i is between a preset first value and a preset second value, 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 moments to obtain the encryption preference classification at any moment.

7. The method for rapid encryption and decryption of text for input method according to claim 1, wherein: The encryption urgency at each moment is the coefficient of variation of the encryption delay acceptance at all moments in a preset period before each moment.

8. The method for rapid encryption and decryption of text for input method according to claim 6, wherein: The expression of the encryption urgency index at each time is: Where, represents the encryption urgency index at time i; represents the encryption preference tag value at time i; represents the encryption urgency at the moment; norm[ ] represents the normalization function.

9. The method for rapid encryption and decryption of text for input method according to claim 1, wherein: The encryption of the text of the input method at the current moment includes: If the encryption urgency index at the current moment 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 enters punctuation or line breaks.

10. A text fast encryption and 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, the steps of the method for rapid text encryption and decryption for an input method as described in any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • Data collection and analysis method

    CN117290884A

  • Network security protection method and system applied to regional digital and intelligent asset business

    CN120281586A

  • Severe care data management system based on block chain

    CN120376021A

  • Association method and apparatus for input method, device and readable storage medium

    WO2020082766A1