Key encryption method, decryption method, electronic equipment and storage medium

By converting the key into a gradient color and generating HTML elements with a gradient color identification, the problem of easy cracking of the key in the prior art is solved, which significantly improves the security and difficulty of the key.

CN119865335APending Publication Date: 2025-04-22CHINA UNICOM SMART CONNECTION TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411907862.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-04-22

AI Technical Summary

Technical Problem

In the prior art, the key may still be cracked by advanced technical means such as code decompilation through plaintext storage, segmented storage, encrypted storage and character replacement, resulting in a threat to key security.

Method used

By converting the key to a gradient color and generating HTML elements with a gradient color identification based on the gradient color, the key is stored using style code to replace the traditional business code storage method.

Benefits of technology

It significantly improves the difficulty of cracking front-end keys, reduces the potential risk of front-end key leakage, and enhances the security of keys by weakening the direct correlation between keys and specific services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119865335A_ABST
    Figure CN119865335A_ABST
Patent Text Reader

Abstract

The invention provides a secret key encryption method, a decryption method, electronic equipment and a storage medium, and the secret key encryption method comprises the steps: obtaining a secret key, converting the secret key into a corresponding gradient color, generating an HTML element with a gradient color identifier according to the gradient color, and converting secret key information into the gradient color, the HTML element with the gradient color identifier is generated according to the gradient color, when the key needs to be called, analysis and reduction are performed, and the key is stored by adopting the style code, so that a traditional service code storage mode is replaced, the direct association between the key and a specific service is effectively weakened, the difficulty of cracking the key by a front end is further remarkably improved, and the service quality of the key is improved. And the potential risk of front-end key leakage is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of web page technology, and in particular to a key encryption method, a decryption method, an electronic device and a storage medium. Background Art

[0002] Keys have a wide range of application scenarios in computer security, mainly used to protect data, verify identity, ensure communication security, etc. The front-end code (HTML, CSS, JavaScript) will be loaded into the user's browser. Anyone who can access the web page can view the source code of the web page through the browser's developer tools. For keys stored on the front end (such as API keys, authentication tokens, etc.), attackers can view these keys directly in the developer tools. The existing plaintext storage method is prone to the risk of key leakage, but the use of diversified storage methods such as segmented storage, encrypted storage and character replacement can still be cracked through advanced technical means such as code decompilation, thereby threatening key security. Summary of the invention

[0003] The present application provides a key encryption method, a decryption method, an electronic device and a storage medium, which help to solve the problem in the prior art that keys stored in various forms such as plain text storage, segmented storage, encrypted storage and character replacement may be cracked through advanced technical means such as code decompilation, thereby threatening the security of the keys.

[0004] In a first aspect, the present application provides a key encryption method, the key encryption method comprising:

[0005] A key is obtained, the key is converted into a corresponding gradient color, and an HTML element with a gradient color identifier is generated according to the gradient color.

[0006] In one possible implementation, the obtaining of the key, converting the key into a corresponding gradient color, and generating an HTML element with a gradient color identifier according to the gradient color includes:

[0007] Get the key, and when the key is in hexadecimal, convert the key into a decimal RGBA array;

[0008] The decimal RGBA array is converted into the gradient color and the HTML element with the gradient color identifier is generated according to the gradient color.

[0009] In one possible implementation, the obtaining of the key, converting the key into a corresponding gradient color, and generating an HTML element with a gradient color identifier according to the gradient color further includes:

[0010] When the key is not in hexadecimal, convert the key into hexadecimal.

[0011] In one possible implementation, the obtaining of the key, when the key is in hexadecimal, converting the key into a decimal RGBA array includes:

[0012] Obtaining a key, and when the key is in hexadecimal, padding the hexadecimal key to generate a hexadecimal string;

[0013] Split the hexadecimal string and convert it into a hexadecimal RGBA array;

[0014] Convert the hexadecimal RGBA array to a decimal RGBA array.

[0015] In a second aspect, the present application provides a key decryption method, the key decryption method comprising:

[0016] When the key needs to be called, the gradient color is parsed from the HTML element with the gradient color identifier, and the gradient color is converted into the key.

[0017] In one possible implementation, when the key needs to be called, parsing the gradient color from the HTML element with the gradient color identifier, and converting the gradient color into the key includes:

[0018] When the key needs to be called, the HTML element with the gradient color identifier is obtained, the gradient color is extracted from it and converted into a decimal RGBA array;

[0019] Convert the decimal RGBA array to the hexadecimal key.

[0020] In one possible implementation, when the key needs to be called, parsing the gradient color from the HTML element with the gradient color identifier, and converting the gradient color into the key further includes:

[0021] When the converted key is not the target key, the key is converted into the target key according to the base of the target key.

[0022] In one possible implementation, converting the decimal RGBA array into the hexadecimal key includes:

[0023] Convert the decimal RGBA array to a hexadecimal RGBA array;

[0024] Concatenate the hexadecimal RGBA array into a hexadecimal string;

[0025] The padding characters in the hexadecimal string are deleted to obtain the hexadecimal key.

[0026] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory, the memory being used to store a computer program; the processor being used to run the computer program to implement a key encryption method as described in any one of the above items or a key decryption method as described in any one of the above items.

[0027] In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a computer, it implements any of the key encryption methods described above or any of the key decryption methods described above.

[0028] The present application provides a key encryption method, which converts key information into gradient colors, generates an HTML element with a gradient color logo based on the gradient colors, and parses and restores the key when it is needed. The key is stored in a style code to replace the traditional business code storage method, which effectively weakens the direct connection between the key and the specific business, thereby significantly improving the difficulty of key cracking at the front end and greatly reducing the potential risk of front-end key leakage. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 A schematic diagram of a key encryption method provided in an embodiment of the present application;

[0030] Figure 2 A schematic diagram of a key decryption method provided in an embodiment of the present application;

[0031] Figure 3 A schematic diagram of a conversion process of a key encryption method provided in an embodiment of the present application;

[0032] Figure 4 A schematic diagram of the analysis process of a key decryption method provided in an embodiment of the present application;

[0033] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] Figure 1 A schematic diagram of a key encryption method provided in an embodiment of the present application, the key encryption method includes:

[0035] Step 101, obtaining a key and converting the key into a corresponding gradient color;

[0036] Step 102: Generate an HTML element with a gradient color logo according to the gradient color.

[0037] The application scenarios of this embodiment mainly involve scenarios that require identity authentication or interaction with back-end systems, where a key refers to a string of characters or codes used to encrypt and decrypt data in computer science and cryptography, and a gradient color refers to a color effect in which two or more colors gradually transition. In computers, colors can be represented by strings. For example, in hexadecimal colors, #FF0000 represents pure red and #00FF00 represents pure green. When the key is obtained, it is converted into the corresponding gradient color according to the key string. For example, when the key is FF000000FF00, the key can be converted into the corresponding hexadecimal colors of pure red and pure green, and then converted into a gradient color, that is, a gradient color of pure red-pure green. At this time, an HTML element with a gradient color identifier is generated according to the converted gradient color, where the identifier is used to uniquely identify the value of an object, entity or data. The identifier here can be an ID or other identifier, which is used to identify the gradient color here. HTML elements are the cornerstone of building a website, including titles, pictures, lists and other information in web pages. For example, HTML elements such as pure red-pure green gradient titles or tables are generated, and whether to hide them is selected according to actual needs.

[0038] Figure 2 A schematic diagram of a key decryption method provided in an embodiment of the present application, the key decryption method comprising:

[0039] Step 201, when a key needs to be called, parse the gradient color from the HTML element with the gradient color identifier;

[0040] Step 202, converting the gradient color into a key.

[0041] When the key needs to be called, the corresponding HTML element is located based on the stored identifier, and the color value of the gradient color is extracted. For example, if the gradient color parsed from the HTML element is a pure red-pure green gradient, then its corresponding hexadecimal string is FF000000FF00. At this time, the parsed string is the target key.

[0042] This embodiment converts key information into gradient colors, generates HTML elements with gradient color logos based on the gradient colors, and parses and restores the keys when they need to be called. It uses style codes to store keys, thereby replacing the traditional business code storage method, effectively weakening the direct connection between keys and specific businesses, thereby significantly improving the difficulty of key cracking at the front end and greatly reducing the potential risk of front-end key leakage.

[0043] Figure 3 A schematic diagram of a conversion process of a key encryption method provided in an embodiment of the present application, the conversion process of the key encryption method includes:

[0044] Step 301, obtaining a key;

[0045] Step 302, determining whether the key is in hexadecimal, if the key is in hexadecimal, executing step 303, if the key is not in hexadecimal, executing step 304;

[0046] Step 303, padding the hexadecimal key;

[0047] Step 304, converting the key into hexadecimal;

[0048] Step 305, split the character string;

[0049] Step 306, converting the segmented character string into a hexadecimal RGBA array;

[0050] Step 307, converting the hexadecimal RGBA array into a decimal RGBA array;

[0051] Step 308, converting the decimal RGBA array into a gradient color;

[0052] Step 309, generating an HTML element with a logo according to the gradient color;

[0053] This embodiment converts the key into a gradient color by performing operations such as padding, splitting, and converting the key, and generates an HTML element with an identifier based on the gradient color, thereby effectively encrypting the key, weakening the direct association between the key and the specific business, and greatly reducing the potential risk of front-end key leakage.

[0054] In one embodiment, obtaining a key, converting the key into a corresponding gradient color, and generating an HTML element with a gradient color identifier according to the gradient color includes:

[0055] Get the key. If the key is in hexadecimal, convert it into a decimal RGBA array.

[0056] Converts a decimal RGBA array to a gradient color and generates an HTML element with a gradient color ID based on the gradient color.

[0057] In this embodiment, when the key is in hexadecimal, the key is converted into a decimal RGBA array, where the decimal RGBA array is one of the formats used to represent colors, and contains four elements, representing red (Red), green (Green), blue (Blue) and transparency (Alpha), for example, pure red, opaque, then the decimal RGBA array is [255, 0, 0, 1]; for example, when the key is 00FF007F0000FF00, it is converted into a decimal RGBA array should be [0, 255, 0, 0.5][0, 0, 255, 0], at this time the decimal RGBA array corresponding to the gradient color is a semi-transparent pure green-fully transparent pure blue gradient color, and then an HTML element with a gradient color identifier is generated according to the gradient color.

[0058] This embodiment converts the hexadecimal key into a decimal RGBA array and then into a gradient color, and finally generates an HTML element with a gradient color logo according to the gradient color. The conversion process is simple and convenient, and also weakens the association between the key and the specific business, thereby enhancing the security of the key.

[0059] In one embodiment, obtaining the key, converting the key into a corresponding gradient color, and generating an HTML element with a gradient color identifier according to the gradient color further includes:

[0060] If the key is not in hexadecimal, convert the key to hexadecimal.

[0061] This embodiment converts a key that is not in hexadecimal format into hexadecimal format, thereby increasing the types of keys that are adaptable to key encryption.

[0062] In one embodiment, obtaining a key, when the key is in hexadecimal, converting the key into a decimal RGBA array includes:

[0063] Get the key. If the key is in hexadecimal format, pad the hexadecimal key to generate a hexadecimal string.

[0064] Split the hexadecimal string and convert it into a hexadecimal RGBA array;

[0065] Convert a hexadecimal RGBA array to a decimal RGBA array.

[0066] In this embodiment, when the key is in hexadecimal, the number of characters in the key string sometimes does not meet the conversion condition. At this time, the hexadecimal key is padded to ensure that its length is a multiple of 8, and a new hexadecimal character string is generated. At this time, the hexadecimal character string is split. For example, the padded character string is FFFFFFFF00000080, which is split and converted into a hexadecimal RGBA array [FFFFFFF] and [00000080], and then the hexadecimal RGBA array is converted into a decimal RGBA array [255, 255, 255, 1][0, 0, 0, 0.5].

[0067] This embodiment converts the hexadecimal key into a decimal RGBA array by methods such as padding and segmentation.

[0068] Figure 4 A schematic diagram of a parsing process of a key decryption method provided in an embodiment of the present application, the key parsing process includes:

[0069] Step 401, obtaining an HTML element with an identifier;

[0070] Step 402, extracting gradient colors;

[0071] Step 403, converting the gradient color into a decimal RGBA array;

[0072] Step 404, converting the decimal RGBA array into a hexadecimal RGBA array;

[0073] Step 405, converting the hexadecimal RGBA array into a hexadecimal string;

[0074] Step 406, deleting the padding string;

[0075] Step 407, converting the string after deleting and padding into a hexadecimal key;

[0076] Step 408, determining whether the hexadecimal key is the target key, if the key is the target key, executing step 409, if the key is not the target key, executing step 410;

[0077] Step 409, obtaining the target key;

[0078] Step 410, converting the key into a binary system;

[0079] After extracting, converting, and deleting the HTML elements with identifiers, this embodiment accurately obtains the final target key, thereby improving the security of the key decryption process.

[0080] In one embodiment, when a key needs to be called, parsing the gradient color from an HTML element with a gradient color identifier, and converting the gradient color into a key includes:

[0081] When the key needs to be called, get the HTML element with the gradient color identifier, extract the gradient color from it and convert it into a decimal RGBA array;

[0082] Convert a decimal RGBA array to a hexadecimal key.

[0083] In this embodiment, when the key needs to be called, the DOM (Document Object Model) operation is used to locate the corresponding HTML element based on the gradient color identifier, and the color value of the gradient color is parsed therefrom, and converted into a decimal RGBA array. For example, the opaque white-semi-transparent black gradient color is parsed therefrom, and the corresponding array converted into decimal RGBA is [255, 255, 255, 1][0, 0, 0, 0.5]; then it is converted into the hexadecimal key FFFFFFFF00000080.

[0084] This embodiment locates the HTML element by identification and extracts the gradient color from it, then converts it into a decimal RGBA array and finally converts it into a target key. This is not only convenient and fast, but also weakens the direct association between the key and the specific business, and further improves the security of the key.

[0085] In one embodiment, when a key needs to be called, parsing the gradient color from an HTML element with a gradient color identifier, and converting the gradient color into a key further includes:

[0086] When the converted key is not the target key, the key is converted into the target key according to the base of the target key.

[0087] In this embodiment, when the final converted hexadecimal key is not the required target key, it is converted into the required key. For example, if the final required target key is a decimal key, the converted hexadecimal key is converted into a decimal key.

[0088] This embodiment accurately restores the encrypted key to the required target key by converting the key.

[0089] In one embodiment, converting a decimal RGBA array to a hexadecimal key includes:

[0090] Convert a decimal RGBA array to a hexadecimal RGBA array;

[0091] Concatenate the hexadecimal RGBA array into a hexadecimal string;

[0092] Delete the padding characters in the hexadecimal string to get the hexadecimal key.

[0093] In the parsing process, this embodiment converts the decimal RGBA array into a hexadecimal RGBA array. For example, the decimal RGBA arrays [255, 255, 255, 1] ​​and [0, 0, 0, 0.5] are converted into hexadecimal RGBA arrays [FFFFFFF] and [00000080], and concatenated into a string FFFFFFFF00000080. If the string is padded during encryption, the padded characters and unnecessary prefix # in the hexadecimal string are deleted at this time to obtain the hexadecimal key.

[0094] This embodiment converts the decimal RGBA array into a hexadecimal key through base conversion, concatenation and deletion.

[0095] Figure 5 A block diagram of an exemplary electronic device 5000 suitable for implementing the embodiments of the present application is shown. Figure 5 The electronic device 5000 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0096] like Figure 5 As shown, the electronic device 5000 is in the form of a general computing device. The components of the electronic device 5000 may include, but are not limited to: one or more processors 5010, a memory 5020, a communication bus 5040 connecting different system components (including the memory 5020 and the processor 5010), and a communication interface 5030.

[0097] The communication bus 5040 represents one or more of several types of bus structures, including a memory bus or a memory control unit, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of a variety of bus structures. For example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnection (PCI) bus.

Claims

1. A key encryption method, characterized in that: The key encryption method comprises: A key is obtained, the key is converted into a corresponding gradient color, and an HTML element with a gradient color identifier is generated according to the gradient color.

2. The key encryption method according to claim 1, characterized in that: The obtaining of the key, converting the key into a corresponding gradient color, and generating an HTML element with a gradient color identifier according to the gradient color includes: Get the key, and when the key is in hexadecimal, convert the key into a decimal RGBA array; The decimal RGBA array is converted into the gradient color and the HTML element with the gradient color identifier is generated according to the gradient color.

3. The key encryption method according to claim 2, characterized in that: The step of obtaining the key, converting the key into a corresponding gradient color, and generating an HTML element with a gradient color identifier according to the gradient color further includes: When the key is not in hexadecimal, convert the key into hexadecimal.

4. The key encryption method according to claim 2, characterized in that: The obtaining of the key, when the key is in hexadecimal, converting the key into a decimal RGBA array comprises: Obtaining a key, and when the key is in hexadecimal, padding the hexadecimal key to generate a hexadecimal string; Split the hexadecimal string and convert it into a hexadecimal RGBA array; Convert the hexadecimal RGBA array to a decimal RGBA array.

5. A key decryption method, characterized in that: The key decryption method comprises: When the key needs to be called, the gradient color is parsed from the HTML element with the gradient color identifier, and the gradient color is converted into the key.

6. The key decryption method according to claim 5, characterized in that: When the key needs to be called, the gradient color is parsed from the HTML element with the gradient color identifier, and the gradient color is converted into the key, which includes: When the key needs to be called, the HTML element with the gradient color identifier is obtained, the gradient color is extracted from it and converted into a decimal RGBA array; Convert the decimal RGBA array to the hexadecimal key.

7. The key decryption method according to claim 5, characterized in that: When the key needs to be called, the gradient color is parsed from the HTML element with the gradient color identifier, and the gradient color is converted into the key, which further includes: When the converted key is not the target key, the key is converted into the target key according to the base of the target key.

8. The key decryption method according to claim 6, characterized in that: The converting the decimal RGBA array into the hexadecimal key comprises: Convert the decimal RGBA array to a hexadecimal RGBA array; Concatenate the hexadecimal RGBA array into a hexadecimal string; The padding characters in the hexadecimal string are deleted to obtain the hexadecimal key.

9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is used to store a computer program; the processor is used to run the computer program to implement the key encryption method according to claims 1-4 or the key decryption method according to claims 5-8.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is run on a computer, the key encryption method according to claims 1 to 4 or the key decryption method according to claims 5 to 8 is implemented.