Data storage method, device and electronic device
By performing decryption, encryption, and updating of the memory storage value of the target variable in the electronic device, the problem of insufficient security of counting variable storage in the memory is solved, and effective protection and security improvement of the stored value are achieved.
Patent Information
- Application Number
- CN202011429801.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-07
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-12-07
AI Technical Summary
Variables used for counting in existing electronic devices are easily tampered with when stored in memory, and memory scanning software can discover their storage addresses, resulting in insufficient security.
By obtaining the stored value of the target variable in the memory, decrypting it to obtain the real value, and then encrypting and updating the stored value after performing the operation to ensure that the stored value does not change with the real value after encryption, thereby avoiding tampering and discovery.
It effectively prevents stored values from being tampered with, reduces the risk of discovery and modification by memory scanning software, and improves the storage security of target variables.
Smart Images

Figure CN112765615B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data storage technology in computer technology. Specifically, a data storage method, device and electronic device are provided. Background Art
[0002] In existing electronic devices, variables are usually used for counting to mark member benefits, for example, to record member usage time. A variable is used in the electronic device to save the remaining usage time, and the variable is decremented over time to record the remaining usage time and store the remaining usage time in the memory of the electronic device. Summary of the invention
[0003] The present disclosure provides a data storage method, device and electronic device.
[0004] According to a first aspect of the present disclosure, there is provided a data storage method, comprising:
[0005] Get the stored value of the target variable in memory;
[0006] Decrypting the stored value to obtain a first variable value of the target variable;
[0007] Performing operation on the first variable value to obtain a second variable value;
[0008] Encrypting the second variable value to obtain a new stored value;
[0009] The storage value stored in the memory is updated to the new storage value.
[0010] According to a second aspect of the present disclosure, there is provided a data storage device, comprising:
[0011] A first acquisition module is used to obtain the storage value of the target variable in the memory;
[0012] A second acquisition module, used for decrypting the stored value to obtain a first variable value of the target variable;
[0013] A third acquisition module, used for calculating the first variable value to obtain a second variable value;
[0014] A fourth acquisition module, used for encrypting the second variable value to obtain a new storage value;
[0015] An updating module is used to update the storage value stored in the memory to the new storage value.
[0016] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform any method described in the first aspect.
[0020] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute any one of the methods described in the first aspect.
[0021] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0023] Figure 1a This is one of the flow charts of the data storage method provided by the embodiment of the present disclosure;
[0024] Figure 1b This is the second flowchart of the data storage method provided by the embodiment of the present disclosure;
[0025] Figure 1c This is the third flow chart of the data storage method provided by the embodiment of the present disclosure;
[0026] Figure 1d This is the fourth flow chart of the data storage method provided by the embodiment of the present disclosure;
[0027] Figure 2 This is the fifth flow chart of the data storage method provided by the embodiment of the present disclosure;
[0028] Figure 3 is a structural diagram of a data storage device provided by an embodiment of the present disclosure;
[0029] Figure 4 It is a block diagram of an electronic device used to implement the data storage method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0030] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0031] See also Figure 1a , Figure 1a is a flow chart of a data storage method provided by an embodiment of the present disclosure, such as Figure 1a As shown, this embodiment provides a data storage method, including the following steps:
[0032] Step 101: Get the storage value of the target variable in the memory.
[0033] The value of the target variable can be understood as a value that needs to change regularly, such as increasing or decreasing. The value stored in the memory is not the real value of the target variable, but the value obtained after encryption to avoid tampering.
[0034] Step 102: decrypt the stored value to obtain a first variable value of the target variable.
[0035] The stored value is the value obtained by encrypting the real value of the target variable. After obtaining the stored value, the stored value is decrypted to obtain the first variable value of the target variable. The first variable value can be understood as the real value of the target variable. The above encryption process and decryption process are inverse processes of each other.
[0036] Step 103: perform operation on the first variable value to obtain a second variable value.
[0037] The operation can be understood as an increment operation or a decrement operation, for example, the first variable value is added by 1, or the variable value is subtracted by 1, to obtain the second variable value.
[0038] Step 104: Encrypt the second variable value to obtain a new stored value.
[0039] The second variable value also needs to be encrypted before being stored in the memory to obtain a new storage value to prevent tampering.
[0040] Step 105: Update the storage value stored in the memory to the new storage value, that is, update the storage value stored at the storage address of the target variable to the new storage value.
[0041] The data storage method in this embodiment can be applied to electronic devices, and the electronic devices can be: mobile phones, tablet computers, laptop computers, personal digital assistants, mobile Internet devices or wearable devices, etc.
[0042] In this embodiment, the storage value of the target variable in the memory is obtained; the storage value is decrypted to obtain the first variable value of the target variable; the first variable value is operated to obtain the second variable value; the second variable value is encrypted to obtain a new storage value; and the storage value stored in the memory is updated to the new storage value. Since the new storage value stored in the memory is encrypted, the storage value can be prevented from being tampered with. At the same time, since the new storage value obtained after encryption does not show regular changes with the change of the real value, it can effectively avoid the scanning of the memory scanning software, ensuring that the memory address of the target variable will not be discovered, and further reducing the risk of the new storage value being modified.
[0043] See also Figure 1b , Figure 1b is a flow chart of a data storage method provided by an embodiment of the present disclosure, such as Figure 1b As shown, this embodiment provides a data storage method, including the following steps:
[0044] Step 106: Obtain a first variable value of the target variable;
[0045] Step 107: Encrypt the first variable value of the target variable to obtain a stored value of the target variable;
[0046] Step 108: Store the stored value in the memory.
[0047] Step 101: Get the storage value of the target variable in the memory.
[0048] Step 102: decrypt the stored value to obtain a first variable value of the target variable.
[0049] Step 103: perform operation on the first variable value to obtain a second variable value.
[0050] Step 104: Encrypt the second variable value to obtain a new stored value.
[0051] Step 105: Update the storage value stored in the memory to the new storage value, that is, update the storage value stored at the storage address of the target variable to the new storage value.
[0052] In the above, before step 101, the above steps 106-107 are also included, that is, the first variable value of the target variable also needs to be encrypted before being stored in the memory, that is, the first variable value of the target variable is encrypted, for example, using Base64 for encryption to obtain the storage value of the target variable. Base64 is a method based on 64 printable characters to represent binary data, which can convert the first variable value into a string, thereby realizing the encryption of the first variable value. The first variable value of the target variable can be obtained from the memory, or from the stack of the electronic device, or it can be a default initial value. After obtaining the storage value, the storage value is stored in the memory to prevent the storage value from being tampered with.
[0053] Furthermore, before encryption, the first variable value may be converted into a character string, and then the character string may be encrypted, which may further improve the security of the first variable value.
[0054] In one embodiment of the present application, the above step 106, obtaining the first variable value of the target variable, includes: determining the first variable value of the target variable, the target variable is a variable used for counting, and the first variable value is an initial value of the target variable;
[0055] Allocating a storage address in the memory for the target variable, wherein the storage address is used to store the first variable value;
[0056] Correspondingly, step 108, storing the stored value in the memory, includes: storing the stored value in the storage address.
[0057] In this embodiment, the target variable is a variable used for counting, for example, a variable used to mark member benefits, and the initial value may be the remaining usage time of the member. A storage address is allocated in the memory for the target variable, and the storage address is used to store the first variable value of the target variable, and the second variable value obtained after subsequent update is also stored in the storage address.
[0058] The initial value of the target variable is encrypted to obtain a storage value, and then the storage value is stored in a storage address. When counting, the storage value is taken out from the storage address, and the storage value is decrypted to obtain the real value (i.e., the first variable value), and the first variable value is added or subtracted, for example, adding 1 or subtracting 1, to obtain the second variable value, and the second variable value is encrypted to obtain a new storage value, and then the new storage value is stored in the storage address. Since the encrypted storage value does not change regularly with the regular changes of the real value, it can effectively avoid the scanning of the memory scanning software, ensuring that the storage address of the target variable will not be discovered. Since the encrypted value is stored in the storage address, even if the scanning software can find the storage address of the target variable, it cannot tamper with the first variable value stored in the storage address, thereby improving the security of the target variable storage.
[0059] See also Figure 1c , Figure 1c is a flow chart of a data storage method provided by an embodiment of the present disclosure, such as Figure 1c As shown, this embodiment provides a data storage method, including the following steps:
[0060] Step 101: Get the storage value of the target variable in the memory.
[0061] Step 102: decrypt the stored value to obtain a first variable value of the target variable.
[0062] Step 1023: Store the first variable value of the target variable on a stack.
[0063] Step 103: perform operation on the first variable value to obtain a second variable value.
[0064] Step 1034: Release the first variable value stored on the stack. This step can also be performed after step 104 or after step 105, which is not limited here, and only needs to be performed after step 103.
[0065] Step 104: Encrypt the second variable value to obtain a new stored value.
[0066] Step 105: Update the storage value stored in the memory to the new storage value, that is, update the storage value stored at the storage address of the target variable to the new storage value.
[0067] In the above, between step 102 and step 103, a step of storing the first variable value of the target variable on a stack is also included. Correspondingly, after step 103, the data storage method further includes: releasing the first variable value stored on the stack.
[0068] In the above, after decrypting the stored value and obtaining the first variable value of the target variable, the first variable value is temporarily stored on the stack of the electronic device, that is, the first variable value is stored on the stack as the value of the temporary variable, and then the first variable value is added or subtracted to obtain the second variable value, which can also be temporarily stored on the stack. Further, after obtaining the second variable value, the first variable value stored on the stack can be released immediately to improve security.
[0069] See also Figure 1d , Figure 1d is a flow chart of a data storage method provided by an embodiment of the present disclosure, such as Figure 1d As shown, this embodiment provides a data storage method, including the following steps:
[0070] Step 106: Obtain a first variable value of the target variable;
[0071] Step 1067: Obtain encryption protection parameters, where the encryption protection parameters include an encryption key and a decryption key.
[0072] Step 107 ′: encrypt the first variable value of the target variable using the encryption key to obtain the storage value of the target variable. This step is a specific implementation of step 107 .
[0073] Step 108: Store the stored value in the memory.
[0074] Step 101: Get the storage value of the target variable in the memory.
[0075] Step 102': decrypt the stored value using the decryption key to obtain the first variable value of the target variable. This step is a specific implementation of step 102.
[0076] Step 103: perform operation on the first variable value to obtain a second variable value.
[0077] Step 104 ′: encrypt the second variable value using the encryption key to obtain the new stored value. This step is a specific implementation of step 104 .
[0078] Step 105: Update the storage value stored in the memory to the new storage value, that is, update the storage value stored at the storage address of the target variable to the new storage value.
[0079] In this embodiment, the encryption protection parameters can be obtained from the server, and the server can be a server that provides services for the software to which the target variable belongs. For example, if the target variable is a parameter of the remaining usage time of a member of a video software, the server can be a server that provides services for the video software, and both the encryption key and the decryption key are provided by the server.
[0080] The encryption key and decryption key can also be automatically generated by the electronic device according to the encryption algorithm. For example, if the target variable is the parameter of the remaining usage time of a video software member, when the user activates the membership, the electronic device automatically generates the encryption key and decryption key according to the encryption algorithm provided by the video software.
[0081] Furthermore, the encryption key and the decryption key can change dynamically. The encryption key and the decryption key can be updated every preset time. It is worth noting that when the encryption key and the decryption key are updated, it is necessary to ensure that the first variable value in the storage address is taken out and the decryption has been completed, so as to avoid the problem that the first variable value in the storage address cannot be decrypted when the encryption key and the decryption key are updated. If the first variable value in the storage address is taken out and the decryption has been completed, after the first variable value is calculated, for example, addition or subtraction, after obtaining the second variable value, the updated encryption key can be used to encrypt the second variable value. The dynamic change of the encryption key and the decryption key can further improve the security of the target variable and prevent the storage value in the memory from being tampered with.
[0082] Furthermore, the first variable value may be displayed on a display interface of the electronic device. Figure 2 As shown, the electronic device reads the ciphertext (i.e., the stored value) from the memory, decrypts the ciphertext, obtains the first variable value, performs addition or subtraction on the first variable value, obtains the second variable value, and uses the second variable value to update the first variable value on the display interface, i.e., displays the second variable value on the display interface. In addition, the second variable value is encrypted to obtain a new ciphertext (i.e., the new stored value), and the new ciphertext is used to update the ciphertext stored at the storage address.
[0083] In the above, the encrypted value is taken out from the storage address. When an operation is required (such as addition and subtraction), the taken out value is first decrypted, and then the operation is performed to obtain the second variable value, and then the second variable value is encrypted to obtain a new ciphertext, and the new ciphertext is stored in the storage address. Since the encrypted ciphertext does not show regular changes with the regular changes of the real value, that is, the encrypted ciphertext does not show regular changes of the real value, it can effectively avoid the scanning of the memory scanning software and ensure that the storage address of the target variable will not be found. Furthermore, since the second variable value stored in the storage address is the encrypted storage value, even if the scanning software finds the storage address of the target variable, it cannot modify the ciphertext. In addition, the decrypted real value is stored on the stack and released immediately after use, which can also improve security.
[0084] See also Figure 3 , Figure 3is a structural diagram of a data storage device provided by an embodiment of the present disclosure, such as Figure 3 As shown, this embodiment provides a data storage device 300, including:
[0085] The first acquisition module 301 is used to acquire the storage value of the target variable in the memory;
[0086] A second acquisition module 302, configured to decrypt the stored value to obtain a first variable value of the target variable;
[0087] A third acquisition module 303, used to operate the first variable value to obtain a second variable value;
[0088] A fourth acquisition module 304 is used to encrypt the second variable value to obtain a new storage value;
[0089] The updating module 305 is used to update the storage value stored in the memory to the new storage value.
[0090] Furthermore, the data storage device 300 further includes:
[0091] A fifth acquisition module, used to acquire a first variable value of the target variable;
[0092] a sixth acquisition module, configured to encrypt the first variable value of the target variable to obtain a stored value of the target variable;
[0093] The first storage module is used to store the storage value in the memory.
[0094] Furthermore, the fifth acquisition module includes:
[0095] A determination submodule, used to determine a first variable value of the target variable, the target variable is a variable used for counting, and the first variable value is an initial value of the target variable;
[0096] an allocation submodule, configured to allocate a storage address in the memory for the target variable, wherein the storage address is used to store the first variable value;
[0097] The first storage module is used to store the storage value to the storage address.
[0098] Furthermore, the data storage device 300 further includes:
[0099] A second storage module, used for storing a first variable value of the target variable on a stack;
[0100] A release module is used to release the first variable value stored on the stack.
[0101] Furthermore, the data storage device 300 further includes:
[0102] A seventh acquisition module, used to acquire encryption protection parameters, wherein the encryption protection parameters include an encryption key and a decryption key;
[0103] a sixth acquisition module, configured to encrypt the first variable value of the target variable using the encryption key to obtain a stored value of the target variable;
[0104] The second acquisition module is used to decrypt the stored value using the decryption key to obtain a first variable value of the target variable;
[0105] The fourth acquisition module 304 is used to encrypt the second variable value using the encryption key to obtain the new stored value.
[0106] The data storage device 300 of the disclosed embodiment obtains the storage value of the target variable in the memory; decrypts the storage value to obtain the first variable value of the target variable; operates the first variable value to obtain the second variable value; encrypts the second variable value to obtain a new storage value; and updates the storage value stored in the memory to the new storage value. Since the new storage value stored in the memory is encrypted, the storage value can be prevented from being tampered with. At the same time, since the new storage value obtained after encryption does not show regular changes with the change of the real value, it can effectively avoid scanning by the memory scanning software, ensuring that the memory address of the target variable will not be discovered, and further reducing the risk of the new storage value being modified.
[0107] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0108] like Figure 4 , is a block diagram of an electronic device according to a method for data storage in accordance with an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0109] like Figure 4As shown, the electronic device includes: one or more processors 501, a memory 502, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 4 A processor 501 is taken as an example.
[0110] The memory 502 is a non-transitory computer-readable storage medium provided by the present disclosure. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the data storage method provided by the present disclosure. The non-transitory computer-readable storage medium of the present disclosure stores computer instructions, which are used to enable a computer to perform the data storage method provided by the present disclosure.
[0111] The memory 502 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the data storage method in the embodiment of the present disclosure (for example, the attached Figure 3 The processor 501 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 502, that is, the data storage method in the above method embodiment is implemented.
[0112] The memory 502 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data created according to the use of the electronic device storing the data, etc. In addition, the memory 502 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 502 may optionally include a memory remotely arranged relative to the processor 501, and these remote memories may be connected to the electronic device storing the data via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0113] The electronic device of the data storage method may further include: an input device 503 and an output device 504. The processor 501, the memory 502, the input device 503 and the output device 504 may be connected via a bus or other means. Figure 4 The example of connecting through bus is taken in the following.
[0114] The input device 503 can receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device for data storage, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick and other input devices. The output device 504 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.
[0115] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0116] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0117] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0118] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0119] The computer system may include clients and servers. The client and server are generally remote from each other and usually interact through a communication network. The server may be a server of a distributed system or a server combined with a blockchain. The relationship of client and server is generated by computer programs running on the respective computers and having a client-server relationship with each other.
[0120] In the present disclosure, the storage value of the target variable in the memory is obtained; the storage value is decrypted to obtain the first variable value of the target variable; the first variable value is operated to obtain the second variable value; the second variable value is encrypted to obtain a new storage value; and the storage value stored in the memory is updated to the new storage value. Since the new storage value stored in the memory is encrypted, the storage value can be prevented from being tampered with. At the same time, since the new storage value obtained after encryption does not show regular changes with the change of the real value, it can effectively avoid the scanning of the memory scanning software, ensure that the memory address of the target variable will not be discovered, and further reduce the risk of the new storage value being modified.
[0121] After obtaining the storage value, the storage value is stored in the memory to prevent the storage value from being tampered with.
[0122] Since the encrypted storage does not change regularly with the real value, it can effectively avoid scanning by memory scanning software and ensure that the storage address of the target variable will not be discovered. Since the encrypted value is stored in the storage address, even if the scanning software can find the storage address of the target variable, it cannot tamper with the first variable value stored in the storage address, thereby improving the security of the target variable storage.
[0123] After decrypting the stored value and obtaining the first variable value of the target variable, the first variable value is temporarily stored on the stack of the electronic device, that is, the variable value is stored on the stack as a temporary variable value, and then the first variable value is added or subtracted to obtain the second variable value, which can also be temporarily stored on the stack. Further, after obtaining the second variable value, the first variable value stored on the stack can be released immediately to improve security.
[0124] Since the encrypted storage value does not show regular changes with the real value, that is, the encrypted storage value does not show regular changes of the real value, it can effectively avoid scanning by memory scanning software and ensure that the storage address of the target variable will not be found. Furthermore, since the first variable value stored in the storage address is the encrypted storage value, even if the scanning software finds the storage address of the target variable, it cannot modify the ciphertext, which can improve security.
[0125] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in this disclosure can be achieved, and this document is not limited here.
[0126] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A data storage method, comprising: Get the stored value of the target variable in memory; Decrypting the stored value to obtain a first variable value of the target variable; Performing an operation on the first variable value to obtain a second variable value, wherein the operation is an increment operation or a decrement operation; Encrypting the second variable value to obtain a new storage value; Updating the storage value stored in the memory to the new storage value; Before obtaining the storage value of the target variable in the memory, the method further includes: Determine a first variable value of the target variable, and allocate a storage address for the target variable in the memory; the target variable is a variable used to mark member benefits, the first variable value is an initial value of the target variable, and the initial value is the remaining usage time of the member; Encrypting the first variable value of the target variable to obtain a stored value of the target variable; The storage value is stored at the storage address.
2. The method according to claim 1, wherein: After decrypting the stored value to obtain the first variable value of the target variable and before operating the first variable value to obtain the second variable value, the method further includes: storing a first variable value of the target variable on a stack; After the operation is performed on the first variable value to obtain the second variable value, the method further includes: The first variable value stored on the stack is released.
3. The method according to claim 1, wherein: Before encrypting the first variable value of the target variable to obtain the stored value of the target variable, the method further includes: Acquire encryption protection parameters, wherein the encryption protection parameters include an encryption key and a decryption key; The step of encrypting the first variable value of the target variable to obtain the stored value of the target variable includes: Encrypting the first variable value of the target variable using the encryption key to obtain a stored value of the target variable; The decrypting the stored value to obtain the first variable value of the target variable includes: Decrypting the stored value using the decryption key to obtain a first variable value of the target variable; The step of encrypting the second variable value to obtain a new stored value includes: The second variable value is encrypted using the encryption key to obtain the new stored value.
4. A data storage device, comprising: A first acquisition module is used to obtain the storage value of the target variable in the memory; A second acquisition module, used for decrypting the stored value to obtain a first variable value of the target variable; A third acquisition module, used for performing an operation on the first variable value to obtain a second variable value, wherein the operation is an increment operation or a decrement operation; A fourth acquisition module, used for encrypting the second variable value to obtain a new storage value; An updating module, used for updating the storage value stored in the memory to the new storage value; Wherein, the data storage device further comprises: a fifth acquisition module, configured to determine a first variable value of the target variable and allocate a storage address for the target variable in the memory, wherein the target variable is a variable used to mark member benefits, the first variable value is an initial value of the target variable, and the initial value is the remaining usage time of the member; a sixth acquisition module, configured to encrypt the first variable value of the target variable to obtain a stored value of the target variable; The first storage module is used to store the storage value to the storage address.
5. The device according to claim 4, wherein: Also includes: A second storage module, used for storing a first variable value of the target variable on a stack; A release module is used to release the first variable value stored on the stack.
6. The device according to claim 4, wherein: Also includes: A seventh acquisition module, used to acquire encryption protection parameters, wherein the encryption protection parameters include an encryption key and a decryption key; a sixth acquisition module, configured to encrypt the first variable value of the target variable using the encryption key to obtain a stored value of the target variable; The second acquisition module is used to decrypt the stored value using the decryption key to obtain a first variable value of the target variable; The fourth acquisition module is used to encrypt the second variable value using the encryption key to obtain the new stored value.
7. An electronic device, wherein: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 3.
8. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 3.
