Encryption processing method and device of webpage data, equipment, storage medium and product
By generating encryption code collaboratively between the client and server, the problem of fixed encryption methods and key information in web applications is solved, enabling flexible adjustments and personalized choices, and reducing replacement costs.
Patent Information
- Application Number
- CN202410918158.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-09
- Publication Date
- 2026-01-09
Smart Images

Figure CN121302383A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a method, apparatus, device, storage medium, and product for encrypting web page data. Background Technology
[0002] With the development of computer technology, users have increasingly higher requirements for the security of web applications. Typically, before initiating a network request, the client encrypts sensitive data such as passwords and phone numbers, and then transmits the encrypted data to the server. This ensures that even if the data is intercepted during transmission, attackers cannot easily decrypt it, thereby reducing the risk of sensitive user data being leaked.
[0003] However, in the current deployment process of web applications, developers typically determine the encryption information used to encrypt sensitive data, such as encryption methods and keys, early in the development process and directly encode this information into the web application's code. This approach limits users' personalized choices of encryption methods and keys and lacks flexibility.
[0004] Therefore, how to deploy encrypted information has become a pressing technical problem that needs to be solved. Summary of the Invention
[0005] This application provides a method, apparatus, device, storage medium, and product for encrypting web page data. The encrypted information associated with the web page loaded by the client is obtained through the server. The encrypted information is not hard-coded into the business code of the web page, which helps to meet the personalized needs of users for encrypted information and makes the encryption processing of web page data more flexible.
[0006] In a first aspect, embodiments of this application provide a method for encrypting webpage data, applied to a client, comprising:
[0007] In response to the loading operation of the target webpage, a first loading request for the target webpage is sent to the server;
[0008] The server receives a response to the first loading request. The response carries the code document of the target webpage. The code document is generated by the server based on the encrypted code and business code corresponding to the target webpage. The encrypted code is generated based on the encrypted information associated with the target webpage.
[0009] The target webpage is loaded based on the business code, and the data to be encrypted obtained from the target webpage is encrypted based on the encryption code.
[0010] Secondly, embodiments of this application provide a method for encrypting webpage data, applied to a server, comprising:
[0011] In response to receiving a first loading request for a target webpage from a client, the system obtains encrypted information and business code associated with the target webpage.
[0012] Based on the encrypted information, encrypted code is constructed, and based on the encrypted code and the business code, the code document of the target webpage is generated;
[0013] The response information carrying the code document is sent to the client. The response information is used to instruct the client to load the target webpage based on the business code and to encrypt the data to be encrypted obtained from the target webpage based on the encryption code.
[0014] Thirdly, embodiments of this application provide a webpage data encryption processing device, applied to a client, comprising:
[0015] The sending unit is used to send a first loading request for the target webpage to the server in response to the loading operation of the target webpage;
[0016] A receiving unit is configured to receive response information returned by the server in response to the first loading request. The response information carries the code document of the target webpage. The code document is generated by the server based on the encrypted code and business code corresponding to the target webpage. The encrypted code is generated based on the encrypted information associated with the target webpage.
[0017] The processing unit is used to load the target webpage based on the business code and to encrypt the data to be encrypted obtained from the target webpage based on the encryption code.
[0018] In one possible implementation, the processing unit is configured to encrypt the data to be encrypted obtained from the target webpage based on the encryption code, specifically for:
[0019] In response to a trigger operation received from the target webpage carrying the data to be encrypted, the data to be encrypted is encrypted based on the encryption information to obtain encrypted data;
[0020] The sending unit is also used to send a web page request carrying the encrypted data to a server that has a background service associated with the triggering operation.
[0021] The receiving unit is further configured to receive operation response information returned by the server in response to the webpage request. The operation response information is obtained by the server after decrypting the encrypted data based on the decryption information associated with the target webpage to obtain decrypted data, and then performing corresponding response processing based on the decrypted data.
[0022] In one possible implementation, the encryption information includes encryption method and key information associated with the target webpage; the business code includes encryption module code; the processing unit is used to encrypt the data to be encrypted based on the encryption information to obtain encrypted data, specifically for:
[0023] The encryption module obtains the encryption method and the key information.
[0024] The encryption module encrypts the data to be encrypted based on the encryption method and the key information to obtain the encrypted data.
[0025] In one possible implementation, the encryption code is obtained by the server adding encryption configuration information as an attribute to the attribute information of a specified object, wherein the encryption configuration information is obtained based on the encryption method, the key information, and configuration information in a preset format.
[0026] Before obtaining the encryption method and the key information through the encryption module, the processing unit is further configured to set the attribute of the specified object to the encryption method and the key information based on the encryption code;
[0027] The processing unit is used to obtain the encryption method and the key information through the encryption module, specifically for:
[0028] The encryption module obtains the encryption method and the key information from the attributes of the specified object.
[0029] In one possible implementation, the processing unit is configured to encrypt the data to be encrypted using the encryption module based on the encryption method and the key information to obtain the encrypted data, specifically for:
[0030] The encryption module obtains the code block corresponding to the encryption method.
[0031] The code block is executed to encrypt the data to be encrypted based on the key information, thereby obtaining the encrypted data.
[0032] In one possible implementation, the sending unit is further configured to send a second loading request for the target webpage to the server in response to a refresh operation of the target webpage;
[0033] The receiving unit is further configured to receive update response information returned by the server in response to the second loading request. The update response information carries an update code document of the target webpage. The update code document is generated by the server based on the update encryption code corresponding to the target webpage and the business code. The update encryption code is generated based on the update encryption information associated with the target webpage.
[0034] The processing unit is further configured to reload the target webpage based on the business code, and encrypt the data to be encrypted obtained from the reloaded target webpage based on the updated encryption code.
[0035] In one possible implementation, the sending unit is further configured to send a connection establishment request carrying webpage information of the target webpage to the server;
[0036] The receiving unit is further configured to receive connection response information returned by the server in response to the connection establishment request, the connection response information being used to indicate that the client and the server have completed the establishment of a communication connection;
[0037] The receiving unit is further configured to receive refresh instruction information sent by the server through the communication connection, the refresh instruction information being used to instruct the client to trigger a refresh operation on the target webpage;
[0038] The refresh instruction information is sent by the server to the client through the communication connection when it detects an update to the encrypted information associated with the target webpage.
[0039] Fourthly, embodiments of this application provide a webpage data encryption processing device, applied to a server, comprising:
[0040] The acquisition unit is used to acquire, in response to receiving a first loading request for a target webpage sent by a client, the encrypted information and business code associated with the target webpage;
[0041] The processing unit is configured to construct encrypted code based on the encrypted information, and generate the code document of the target webpage based on the encrypted code and the business code;
[0042] The sending unit is used to send response information carrying the code document to the client. The response information is used to instruct the client to load the target webpage based on the business code and to encrypt the data to be encrypted obtained from the target webpage based on the encryption code.
[0043] In one possible implementation, the encryption information includes encryption method and key information associated with the target webpage, and the processing unit is configured to construct encryption code based on the encryption information, specifically for:
[0044] Obtain configuration information in a preset format, and fill the encryption method and the key information into the configuration information according to the preset format to obtain encryption configuration information;
[0045] The encryption configuration information is added as an attribute to the attribute information of a specified object to obtain the encryption code. The encryption code is used to instruct the client to set the attribute of the specified object to the encryption information and the key information.
[0046] In one possible implementation, the processing unit is configured to generate a code document for the target webpage based on the encrypted code and the business code, specifically for:
[0047] The encryption code is added to the business code according to the development format of the specified development language used in the business code;
[0048] The code document is generated based on the added business code.
[0049] In one possible implementation, the webpage data encryption processing device further includes a receiving unit for receiving a webpage request carrying encrypted data sent by the client. The webpage request is sent by the client after encrypting the data to be encrypted based on the encryption information.
[0050] The processing unit is further configured to acquire decryption information associated with the target webpage, and decrypt the encrypted data based on the decryption information to obtain decrypted data;
[0051] The processing unit is further configured to perform corresponding response processing based on the decrypted data, obtain operation response information, and send the operation response information to the client.
[0052] In one possible implementation, the processing unit is configured to acquire decryption information associated with the target webpage, and decrypt the encrypted data based on the decryption information to obtain decrypted data, specifically for:
[0053] The decryption information is obtained by a decryption module deployed on the server. The decryption information includes the encryption method and decryption key information associated with the target webpage.
[0054] The decryption module decrypts the encrypted data based on the encryption method and the decryption key information to obtain the decrypted data.
[0055] In one possible implementation, the receiving unit is further configured to receive a second loading request sent by the client in response to the refresh operation of the target webpage;
[0056] The processing unit is further configured to, in response to the second loading request, obtain the updated encrypted information associated with the target webpage and the business code;
[0057] The processing unit is further configured to construct update encryption code based on the update encryption information, and generate update code document for the target webpage based on the update encryption code and the business code;
[0058] The sending unit is further configured to send update response information carrying the update code document to the client. The update response information is used to instruct the client to reload the target webpage based on the business code and to encrypt the data to be encrypted obtained from the reloaded target webpage based on the update encryption code.
[0059] In one possible implementation, the receiving unit is further configured to receive a connection establishment request sent by the client, which carries webpage information of the target webpage;
[0060] The sending unit is further configured to send connection response information to the client in response to the connection establishment request, the connection response information being used to instruct the client and the server to complete the establishment of a communication connection;
[0061] The sending unit is further configured to send refresh instruction information to the client when it detects an update to the encrypted information associated with the target webpage, the refresh instruction information being used to instruct the client to trigger a refresh operation on the target webpage.
[0062] Fifthly, embodiments of this application provide an electronic device, which includes one or more processors; and a memory for storing one or more computer programs, which, when executed by the one or more processors, cause the electronic device to implement the web page data encryption processing method described in the first aspect or the second aspect.
[0063] Sixthly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the web page data encryption method described in the first or second aspect.
[0064] In a seventh aspect, embodiments of this application provide a computer program product, which includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, they implement the web page data encryption processing method as described in the first aspect or the second aspect.
[0065] In some embodiments of this application, the technical solutions involve a client sending a loading request to a server when loading a webpage. The server obtains the encrypted information associated with the webpage loaded by the client, generates encrypted code based on the encrypted information, and returns a code document containing the webpage's business code to the client. The client can then load the webpage based on the business code and encrypt the data obtained from the webpage using the encrypted code. It is evident that the encrypted information associated with the webpage is obtained by the server upon receiving the webpage loading request and is not written into the webpage's business code. The encrypted information is decoupled from the webpage's business code. Therefore, the encryption method and key information associated with the webpage are not fixed in the code and can be switched and modified at the data source of the encrypted information obtained by the server. This facilitates meeting users' personalized needs for encryption methods and key information and makes the deployment of encryption methods and key information more flexible. Furthermore, modifying the encrypted information at the data source obtained by the server does not require changing the webpage's business code, thus eliminating the need to redeploy the entire webpage application and making the modification of encrypted information more convenient. Attached Figure Description
[0066] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0067] Figure 1 This is a schematic diagram of the architecture of a web page data encryption processing system provided in an embodiment of this application;
[0068] Figure 2 This is a flowchart illustrating a webpage data encryption method provided in an embodiment of this application;
[0069] Figure 3 This is a timing diagram illustrating how a client loads a target webpage, as provided in an embodiment of this application.
[0070] Figure 4 This application provides another flowchart illustrating a method for encrypting webpage data.
[0071] Figure 5This is a timing diagram illustrating a client sending a webpage request to a server, provided in an embodiment of this application.
[0072] Figure 6 This is a system architecture diagram of a web page data encryption processing method provided in an embodiment of this application;
[0073] Figure 7 This is another flowchart illustrating a method for encrypting webpage data provided in this application embodiment;
[0074] Figure 8 This is a schematic diagram of the structure of a web page data encryption processing device provided in an embodiment of this application;
[0075] Figure 9 This is a schematic diagram of another web page data encryption processing device provided in the embodiments of this application;
[0076] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0077] It should be noted in advance that, in order to enable those skilled in the art to better understand the technical solutions proposed in the embodiments of this application, the embodiments of this application will be described clearly and completely in conjunction with one or more accompanying drawings. Furthermore, the various drawings shown in the embodiments of this application are merely illustrative examples; for example, the execution order of each step in the drawings can be adaptively adjusted according to the actual application scenario. In addition, in the embodiments of this application, the block diagrams shown in the various drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, or in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0078] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0079] It should be noted that "multiple" in this article refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0080] During communication between the client and server of a web application, it was observed that current web applications, especially those with high security requirements, encrypt sensitive data such as phone numbers, passwords, and transaction data before sending a network request to the server (transmission encryption). The encrypted data is then transmitted to the server via Hypertext Transfer Protocol (HTTP) or other protocols. Encryption methods can include asymmetric encryption, such as the Rivest–Shamir–Adleman (RSA) algorithm, which involves a public-key and private-key pair. The client can encrypt the data using the public key before sending the request, and the server can decrypt it using the private key upon receiving the encrypted data. Therefore, even if the data is intercepted during transmission, attackers cannot easily decode the encrypted data, thus ensuring data transmission security. However, before deploying a web application, developers typically determine the encryption method and key information used for transmitting sensitive data and incorporate this into the application's code. This approach, to some extent, limits users' customization options for encryption methods and key information within the web application. For already deployed web applications, although the encryption method and key information are generally not changed after deployment, if it is necessary to change the encryption method or key information, such as changing the encryption method or changing the public and private keys, the web application code needs to be redeployed, which is a cumbersome operation and has a high cost.
[0081] Based on this, embodiments of this application provide a method for encrypting webpage data. Instead of embedding the encryption information in the webpage's business code, the server obtains the encrypted information from the webpage's encryption after receiving a loading request from the client and returns it to the client. This decouples the encryption information from the webpage's business code. In other words, the encryption method and key information associated with the webpage are not fixed in the code; they can be switched and modified at the data source of the encryption information obtained from the server. This facilitates meeting users' personalized needs for encryption methods and key information and makes the deployment of encryption methods and key information more flexible. Furthermore, modifying the encryption information at the data source obtained from the server does not require changing the webpage's business code, thus eliminating the need to redeploy the entire webpage application and making the modification of encryption information more convenient.
[0082] Based on the above description, please refer to Figure 1 , Figure 1 This is a schematic diagram of the architecture of a web page data encryption processing system provided in an embodiment of this application, such as... Figure 1 As shown, the webpage data encryption system includes a client device 101, a web application server 102, an encryption service server 103, and a database for storing encrypted information. The client device 101 can be directly or indirectly connected to the web application server 102 via wired or wireless means, and the web application server 102 can also be directly or indirectly connected to the encryption service server 103 via wired or wireless means. The encryption service server 103 can access data in the database. It should be noted that... Figure 1 The number and configuration of devices shown are for illustrative purposes only and do not constitute a limitation on the embodiments of this application. In some embodiments, the client device 101 can access data in the database to obtain encrypted information. In some embodiments, the web application server 102 and the encryption service server 103 can be the same electronic device.
[0083] In this embodiment, the client device 101 is an electronic device, specifically a terminal device. Terminal devices can include, but are not limited to, smartphones (such as Android phones, iOS phones, etc.), tablets, portable personal computers, mobile internet devices (MIDs), smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, wearable devices, etc. This embodiment does not limit the specific type of terminal device. It should be noted that the client device 101 can be an electronic device that supports running web applications and sending web page requests to the server. The web application server 102 and the encryption service server 103 can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. This embodiment does not limit the specific type of cloud server. The database can be a database used to store encrypted information associated with each web page; it can be a cloud-stored database or a locally stored database. This embodiment does not limit the specific type of database.
[0084] The client device 101 can be a device used by the user, an electronic device that can run web applications, such as a browser program installed in the client device 101, which can load and render the target web page based on the web page's code document to run web applications, such as outputting the web page's user interface. The client device 101 can also receive user operations on the target web page loaded by the browser and initiate web page requests.
[0085] The web application server 102 can be a server running middleware service software or a backend server running software that provides backend services for web pages. In this embodiment, the web application server 102 can run both middleware service software, such as Node.js, and software that provides backend services for web pages.
[0086] Specifically, when the web application server 102 runs Node.js software, it can also be referred to as a middleware server, a Node server, or a front-end middleware (Node). The web application server 102 can act as an intermediary between the front-end (such as the browser running on the client device 101) and the back-end (such as a database or other services), handling tasks such as permission verification and data format conversion, making front-end and back-end interaction more flexible and secure. In this embodiment, the web application server 102 can act as a middleware server to receive a loading request from the client device 101 to load a webpage, obtain the encrypted information associated with that webpage, generate encrypted code, and return the code document containing the webpage's business code to the client device 101.
[0087] Specifically, when the web application server 102 runs software that provides background services for the webpage, the web application server 102 can also be called a background server, backend server, etc. The web application server 102 can be used to handle tasks such as business logic of the web application, data processing, and data storage. In this embodiment, after the browser running on the client device 101 loads the webpage, subsequent operations input by the user on the webpage through the client device 101 can be interactions with the web application server 102, which runs software that provides background services for the webpage. A web application can include multiple business logics, each of which can be understood as a different function provided by the webpage, and each business logic can be implemented by a separate backend server. The web application server 102 can act as a server for a background service associated with a certain function in the webpage, receiving webpage requests sent by the client device 101, obtaining decryption information associated with the webpage, decrypting the encrypted data carried by the webpage request based on the decryption information, and performing corresponding response processing according to the decrypted data to obtain operation response data returned to the client device 101.
[0088] Among them, the encryption service server 103 is a server that provides encryption services. It can be the same server as the web application server 102. The encryption service server 103 can be understood as a server that can communicate with the client device 101 and the web application server 102 when they need to obtain encryption and decryption information in order to obtain the encryption and decryption information.
[0089] The general process of the webpage data encryption method provided in this application is as follows:
[0090] In response to a target webpage loading operation, client device 101 sends a loading request to web application server 102. Web application server 102, in response to this loading request, can obtain the encrypted information and business code associated with the target webpage. Specifically, web application server 102 can send a request to encryption service server 103 to obtain encrypted information. Encryption service server 103 can query the encrypted information associated with the target webpage from its database and return it to web application server 102. After receiving the encrypted information returned by encryption service server 103, web application server 102 can construct encrypted code based on the encrypted information, and generate a code document for the target webpage based on the encrypted code and the business code. It then sends a response message carrying the code document to client device 101. Client device 101 can then load the target webpage based on the business code in the code document, and further output the loaded target webpage. It can also encrypt the data to be encrypted obtained from the target webpage based on the encrypted code.
[0091] In one implementation, the aforementioned encrypted information, encrypted code, business code, code documentation, etc., can all be stored in the blockchain, preventing this information from being tampered with. Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, it is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block.
[0092] It is understood that the web page data encryption processing system described in the embodiments of this application is for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and does not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0093] Based on the encryption system for the aforementioned webpage data, please refer to [link / reference]. Figure 2 , Figure 2 This is a flowchart illustrating a method for encrypting webpage data, provided in this application embodiment. This method can be implemented through interaction between a client and a server. The client can be... Figure 1 The client device 101 shown can be a server. Figure 1 The web application server 102 shown may include the following steps S201-S205 for encrypting web page data:
[0094] S201. In response to the loading operation of the target webpage, the client sends a first loading request for the target webpage to the server. Correspondingly, the server receives the first loading request for the target webpage sent by the client.
[0095] Web applications are typically divided into front-end and back-end. The front-end, often called the client-side, is the part of the web application that users directly interact with. For example, the front-end refers to the website pages, forms, controls, images, videos, etc., included in the web application. Users can browse these website pages, forms, controls, images, videos, etc. (front-end). The main task of front-end development is to transform the web design into a visual page and implement corresponding interactive functions. Front-end development languages can include Hypertext Markup Language (HTML), Cascading Style Sheets (CSS), JavaScript, etc. The back-end, often called the server or server-side, is the part that handles the business logic of the web application, processes data, and stores data. The main task of back-end development is to implement business logic and data processing, and provide interfaces for the front-end to call. Back-end development languages can include Java, Python, Hypertext Preprocessor (PHP), Golang (GO), etc.
[0096] In this application embodiment, the aforementioned client can refer to an electronic device capable of running browser software. Browser software is a software tool for users to view front-end content, which can present the front-end code to the user. That is, the user can access and view the content on the webpage through the browser software installed in the client and interact with the dynamic functions provided by the webpage. The target webpage refers to the webpage that the user wants to access. The loading operation of the target webpage responded to by the client can refer to the operation that triggers the loading of the target webpage. For example, it can be a loading operation triggered by the user entering the URL information of the target webpage in the browser, or it can be a loading operation triggered by other programs or webpages that navigate to the target webpage. This application does not limit this.
[0097] In this embodiment, the server from which the client sends the first loading request does not refer to a server providing backend services, but rather to a server running middleware services, i.e., a server that acts as an intermediary between the frontend and backend, such as a Node.js server. This server can also be called a middleware server, a node server, or a frontend middleware (node), etc. It is a server built using the Node.js technology stack, providing a runtime environment for JavaScript code on the server side. It can handle tasks such as permission verification and data format conversion, making frontend-backend interaction more flexible and secure. The first loading request can be an HTTP request sent by the client to request the content of the target webpage in order to load the webpage on the client side.
[0098] In one possible implementation, the client can respond to the loading operation of the target webpage. For example, a user enters the Uniform Resource Locator (URL) of the target webpage into the address bar of the browser software running on the client, generating an HTTP request, i.e., the first loading request. The client then resolves the domain name contained in the URL to the corresponding Internet Protocol Address (IP address) through the Domain Name System (DNS), and establishes a communication connection with the server (such as a Node.js server) based on this IP address. This connection typically uses a Transmission Control Protocol (TCP) connection, usually a three-way handshake, to ensure reliable data transmission. After establishing a communication connection between the client and the server, the client can send the first loading request to the server to request a specific resource, such as retrieving the content of the target webpage. Upon receiving the first loading request, the server can then perform a series of processing steps in response.
[0099] S202. Upon receiving the first loading request for the target webpage sent by the client, the server obtains the encrypted information and business code associated with the target webpage.
[0100] In this embodiment, the encrypted information may include an encryption method and key information. The encryption method refers to a method of changing the original information data through a special algorithm, and the key information refers to information including the correspondence between the password and the plaintext. The encrypted information associated with the target webpage refers to the encryption method and key information used to transmit sensitive data (data to be encrypted) on the target webpage. This information can be user-configured or default; this application does not limit this. Since the encrypted information is associated with the target webpage, and one webpage can correspond to one type of encrypted information, this encrypted information can be called system-level encrypted information, specifically system-level encryption method and key information. In the case of asymmetric encryption, the key information can refer to the public key of the asymmetric encryption algorithm. For example, if the encryption method is based on the RSA algorithm, the key information is the public key of the RSA algorithm. The business code associated with the target webpage can refer to code running on the client side, which can be used to display the page content of the target webpage and implement user interaction. The business code can be written in languages such as HTML, CSS, and JavaScript.
[0101] In one possible implementation, upon receiving an HTTP request (the first load request), the server can first query the resource corresponding to the requested URL, i.e., the resource corresponding to the target webpage. This resource can include HTML documents, CSS stylesheets, JavaScript scripts, images, audio, etc. The HTML document defines the content and structure of the webpage; the CSS stylesheet describes the styles related to the content of the webpage within the HTML document, including colors, layout, and fonts; and the JavaScript script can be used to control the behavior of the webpage, such as responding to user clicks, dynamically modifying page content, and sending requests. It should be noted that CSS stylesheets can be inlined in the HTML document, such as using the `style` attribute directly within HTML elements, or they can be linked to the HTML document as external files via a URL. JavaScript scripts can also be embedded in the HTML document, such as using... <script>标签,也可以作为外部文件通过相应的语法引用在HTML文档中。服务器所获取到的图片、音频等资源可以通过诸如、<audio>等HTML元素引用在HTML文档中,并通过URL链接到具体的资源文件。在本申请实施例中,业务代码可以指该HTML文档中所包括的,用于描述目标网页的页面内容,实现与用户交互的代码。
[0102] 在本申请实施例中,不同的用户可以针对所使用的网页应用设置所需要的加密信息。该网页应用例如可以是私有云场景中网页应用,在私有云的场景下,不同用户可以使用采用同一套代码编写的网页应用。该私有云场景中的网页应用例如可以是企业的内部管理系统,用于管理员工的个人信息、考勤、薪资等数据。不同企业的管理人员可以是指私有云场景下的用户,在使用内部管理系统时,不同企业对于加密方式和密钥信息的需求可以是不同的,则企业的管理人员可以设置不同的加密方式和密钥信息。由此,服务器获取与目标网页关联的加密信息可以是获取当前环境(私有云环境)中与该目标网页关联的加密信息,也即是获取当前环境中与该目标网页关联的加密方式和密钥信息。
[0103] 在一种实现方式中,服务器可以基于目标网页从数据库中查询与该目标网页关联的加密信息,例如数据库中可以存储有网页与加密信息的对应关系,服务器通过在数据库中进行查询,可以得到与目标网页关联的加密方式和密钥信息。
[0104] 在又一种实现方式中,服务器中也可以存储有与网页所需的配置信息的文本文件,即配置文件,该配置文件中可以存储有与目标网页关联的加密信息,服务器可以从配置文件中获取与该网页关联的加密信息,得到与该目标网页关联的加密方式和密钥信息。
[0105] 在另一种实现方式中,该服务器还可以从环境变量中用于指定操作系统运行环境的参数中,获取与目标网页关联的加密信息。
[0106] 在再一种实现方式中,其他服务器中可以部署有加密服务,其他服务器可以称为加密服务器(secret server),该加密服务可以理解为一种程序。加密服务器可以如图1所示的加密服务服务器103,服务器可以向部署有加密服务的其他服务器发送与目标网页关联的加密信息获取请求,其他服务器响应于该服务器发送的请求,可以获取与目标网页关联的加密信息,例如通过在数据库中查询、在配置文件中获取、在环境变量中获取、再转发给其他电子设备获取等方式,得到与该目标网页关联的加密信息。进而,该其他服务器可以将获取到的加密信息返回至该服务器。其中,本申请对服务器获取与目标网页关联的加密信息的方式不做限定。在服务器获取到加密信息后,例如服务器接收到其他服务器发送的与目标网页关联的加密信息后,可以进行进一步处理,以对第一加载请求进行响应。
[0107] S203、服务器根据加密信息构建加密代码,并根据加密代码和业务代码生成目标网页的代码文档。
[0108] 在本申请实施例中,加密信息为包括与目标网页关联加密方式和密钥信息的信息。加密代码是指包括与该目标网页关联的加密方式和密钥信息的代码,可以由客户端运行,以获取到该目标网页的加密方式和密钥信息。业务代码可以是指服务器获取到的描述目标网页的页面内容,实现与用户交互的代码,目标网页的代码文档可以是基于业务代码和加密代码生成的代码文档,可以包括业务代码和加密代码,其中,该代码文档格式可以是HTML格式的,该代码文档也可以称为HTML文档。
[0109] 在一种可能的实现方式中,服务器可以获取预设格式的配置信息,并将获取到的与目标网页关联的加密方式和加密信息按照该预设格式填入配置信息中,得到加密配置信息。其中,配置信息可以是指服务器构造的数据结构,例如预设格式的配置信息为{transportSecret:{method:"",public_key:""}}。服务器构造数据结构的目的是为了将获取到的加密方式和密钥信息转换为预设格式的数据,以便客户端可以方便地解析和使用这些数据。服务器获取配置信息后,可以将加密方式按照预设格式填入配置信息,例如,将加密方式填入method对应的""中,并将密钥信息,在加密方式为基于非对称加密时,密钥信息可以为该加密方式对应的公钥填入public_key对应的""中,得到加密配置信息,加密配置信息可以如{transportSecret:{method:”加密方式",public_key:"公钥"}}所示。
[0110] 可选地,服务器也可以直接根据加密方式和密钥信息生成预设格式的配置信息,得到加密配置信息。也就是说,服务器可以直接基于加密方式和密钥信息构造数据数据结构,得到加密配置信息,例如,服务器可以直接根据加密方式和密钥信息生成如{transportSecret:{method:”加密方式",public_key:"公钥"}}所示的加密配置信息。
[0111] 进一步地,服务器可以将加密配置信息作为属性添加在指定对象的属性信息中,得到加密代码。需要说明的是,由于服务器运行有中间层服务的软件的服务器,例如为Node.js服务器,其能够提供一个JavaScript的运行环境,因此该Node.js服务器可以用于生成基于JavaScript语言的加密代码。其中,该指定对象可以是JavaScript对象,该JavaScript对象也可以称为变量,其属性信息可以包括该对象的多个属性。例如,该指定对象可以是window对象,其是一个全局对象,表示浏览器的窗口或者标签页,可以提供了浏览器窗口相关的各种属性和方法,例如窗口的大小等。再例如,该指定对象可以是前端开发人员定义的对象,服务器可以定义该对象的属性。为描述方便,本申请实施例以window对象为例,将该加密配置信息定义为window对象的属性,得到加密代码。例如加密代码可以是window.transport={transportSecret:{method:"加密方式",public_key:"公钥"}}。其中,transport为在window对象下添加的属性,其具体包括加密方式(method)和密钥信息(public_key),其属性的值例如可以是在加密配置信息中填入的加密方式和公钥。
[0112] 在服务器得到加密代码之后,可以根据加密代码和业务代码生成目标网页的代码文档,具体可以按照业务代码所采用的开发语言的开发格式,将加密代码添加在业务代码中,例如加密代码为包括JavaScript对象的属性的代码,则可以将该加密代码以基于<script>标签的格式添加在业务代码中,这个内嵌的过程可以称为将加密代码注入至业务代码中。进而,服务器可以基于添加加密代码后的业务代码生成代码文档,也即是服务器可以将注入了加密代码后的业务代码的HTML文档作为该目标网页的代码文档。其中,上述服务器将加密方式和密钥信息定义为指定对象(如window对象)的属性得到加密代码,并基于加密代码和业务代码生成代码文档的过程可以称为将数据结构在即将返回给前端的HTML文档中,且注入到window下。
[0113] S204、服务器将携带代码文档的响应信息发送至客户端。相应的,客户端接收服务器响应于第一加载请求返回的响应信息。
[0114] 在服务器得到目标网页的代码文档之后,可以将该代码文档封装在HTTP响应信息中,并发送回客户端。例如,该响应信息可以包括状态码、响应头信息、以及响应体,在该响应体中,可以包括该目标网页的代码文档。相应的,客户端可以接收该响应信息,并获取该响应信息携带的代码文档。
[0115] S205、客户端基于业务代码加载目标网页,并基于加密代码对从目标网页获取到的待加密数据进行加密处理。
[0116] 在本申请实施例中,客户端在获取到响应信息携带的代码文档之后,可以基于代码文档中的业务代码加载目标网页。例如,该业务代码中包括HTML语言编写的定义的目标网页的结构和内容的代码,CSS语言编写的定义网页的样式的代码,以及JavaScript语言编写的实现交互功能的代码,则客户端可以按照代码的指示来渲染和输出目标网页,以加载出该目标网页。客户端在获取到响应信息携带的代码文档之后,可以基于加密代码对后续从目标网页获取到的待加密数据进行加密处理,其中,待加密数据可以是用户与目标网页进行交互中产生的敏感数据,如用户的手机号、邮箱、密码登等数据。
[0117] 其中,客户端在接收到加密代码之后,可以基于加密代码将指定对象的属性设置为该加密方式和密钥信息,后续客户端在对待加密数据进行加密时可以从指定对象的属性中获取加密方式和密钥信息。示例性的,以加密代码为window.transport={transportSecret:{method:"加密方式",public_key:"公钥"}}为例进行讲解,客户端可以基于加密代码,在指定对象,如window对象上设置一个名为transport的属性,该属性包括method(加密方式)和public_key(公钥)两个具体的属性值。由于该transport的属性被设置在window对象上,客户端所执行的JavaScript代码,无论是与该加密代码在同一<script>标签内,还是在其他<script>标签中,或者是在事件处理函数中,均可以通过window.transport或者transport访问该对象以及其属性,从而读取到(获取到)加密方式和公钥(密钥信息),进而可以对待加密数据进行加密处理。
[0118] 请一并参阅图3,图3是本申请实施例提供的一种客户端加载目标网页的时序示意图。图3以服务器与部署有加密服务的其他服务器进行交互,以获取与目标网页关联的加密信息为例进行讲解和绘制。如图3所示,首先,客户端可以向服务器发起针对目标网页的第一加载请求,相应的,该第一加载请求到达服务器,即服务器接收该第一加载请求。进而,服务器可以获取与目标网页关联的加密信息。具体地,服务器可以向部署有加密服务的其他服务器发起加密信息的获取请求,以获取加密信息,例如服务器可以获取当前环境下(例如该目标网页所在的私有云环境下)与目标网页关联的加密方式和该加密方式下的密钥信息(公钥)。
[0119] 进一步地,在该获取请求到达其他服务器后,其他服务器响应于该获取请求,可以采用不同方式获取加密信息,例如从数据库、环境变量、配置文件或者其他方式获取该与目标网页关联的加密信息。进而,其他服务器可以将包括加密方式和密钥信息的加密信息返回至服务器。服务器可以将获取到的加密方式和密钥信息填入获取到的预设格式的配置信息中,得到加密配置信息,如服务器可以基于获取到的加密信息构造包括加密方式和密钥信息的数据结构,如{transportSecret:{method:”加密方式",public_key:"公钥"}}所示,进而将加密配置信息作为属性添加在指定对象的属性信息中,得到加密代码,如上述添加在window对象的属性信息中,如window.trasport={transportSecret:{method:”加密方式",public_key:"公钥"}}所示。
[0120] 进一步地,服务器可以根据加密代码和业务代码生成目标网页的代码文档,即服务器可以将加密代码添加在业务代码中,并基于添加后的业务代码生成代码文档,得到返回客户端的HTML文档。最后,服务器可以将携带该代码文档的响应信息发送至客户端,以指示客户端可以基于业务代码加载目标网页,并基于加密代码对从目标网页中获取的待加密数据进行加密处理。在客户端基于业务代码加载目标网页之后,客户端可以输出该目标网页的用户界面,例如客户端通过运行的浏览器软件展示该目标网页的页面,进而客户端可以基于输出的目标网页与用户进行交互,如接收用户针对目标网页中的控件输入的操作。
[0121] 在本申请中的一些实施例所提供的技术方案中,通过客户端在加载网页时,向服务器发送加载请求,服务器获取与客户端所加载的网页关联的加密信息,并基于加密信息生成加密代码,与该网页的业务代码生成代码文档后返回客户端,进而客户端可以基于业务代码加载该网页,并基于加密代码对从该网页中获取到的待加密数据进行加密处理。可见,与网页关联的加密信息是服务器接收到网页的加载请求后获取的,并不编写在该网页的业务代码中,该网页的加密信息与该网页的业务代码解耦,因此,与网页关联的加密方式和密钥信息不是固定在代码中的,可以在服务器获取的加密信息的数据源处对其进行切换和修改,有利于满足用户针对加密方式和密钥信息的个性化的需求,也使得加密方式和密钥信息的部署更为灵活。并且,在服务器获取的数据源处对加密信息进行修改,可以无需改动该网页的业务代码,也就无需重新部署整个网页应用,使得加密信息的修改更加便捷。
[0122] 请参阅图4,图4是本申请实施例提供了一种网页数据的加密处理方法的另一流程示意图,该网页数据的加密处理方法可由客户端和服务器交互实现。其中,客户端可以是图1所示的客户端设备101,服务器可以是图1所示的网页应用服务器102,该网页数据的加密处理方法可以包括以下步骤S401-S405,其中:
[0123] S401、客户端响应于基于目标网页接收到携带待加密数据的触发操作,基于加密信息对待加密数据进行加密处理,得到加密数据。
[0124] 在本申请实施例中,触发操作可以是用户与目标网页进行交互时所输入的操作,在交互的过程中涉及的敏感数据可以称为待加密数据。例如,目标网页是一个登陆网页,用户可以通过输入用户名、密码后针对登陆控件输入登陆操作,该登陆操作可以携带用户输入的用户名和密码。在这个过程中,登陆操作可以理解为客户端接收到的触发操作,该登陆操作携带的用户名和密码,或者仅是密码可以作为待加密数据。进而,客户端可以对待加密数据进行加密处理,得到加密数据。
[0125] 其中,客户端在加载该目标网页时,基于加密代码将与目标网页关联的加密信息包括的加密方式和密钥信息部署在指定对象的属性中,例如部署在window对象的属性中,则客户端可以从指定对象的属性中获取该加密方式和密钥信息。进而,客户端可以基于获取到的加密方式和密钥信息,如公钥,对待加密数据进行加密处理,得到加密数据。需要说明的是,客户端在接收到触发操作之后,可以执行相应的JavaScript代码对待加密数据进行加密,在相应的JavaScript代码中,可以通过window.transport或者transport的方式访问该window对象以及其属性,相当于客户端在对待加密数据进行加密处理的过程中,从该指定对象的属性中获取到加密方式和密钥信息。
[0126] 在一种可能的实现方式中,业务代码中可以包括加密模块的代码,该加密模块可以理解业务代码中用于实现加密功能的代码,可以为一个包括加密功能的软件开发工具包(Software Development Kit,SDK),用于对需要向服务器发请求时所涉及的待加密数据进行加密。由此,客户端可以响应于触发操作,通过加密模块获取与目标网页关联的加密方式和密钥信息,具体可以通过所述加密模块从指定对象的属性,例如上述window对象的属性中获取该加密方式和该密钥信息。进而通过该加密模块基于加密方式和密钥信息对待加密数据进行加密处理,得到加密数据。需要说明的是,通过在业务代码中部署加密模块的代码,可以将客户端所要执行的与加密相关的程序均抽离到SDK中,与加密相关的逻辑均由该SDK进行统一处理,因此该SDK可以称为加密SDK,由于该SDK是由JavaScript语言编写的,该SDK也可以称为jsSDK。
[0127] 可以理解的是,若业务代码中没有将加密模块抽离出来,即没有SDK将加密逻辑和业务代码解耦之前,业务代码中需硬编码对待加密数据进行加密的加密方式和密钥信息,例如对待加密数据(如邮箱信息)进行加密所涉及的具体代码可以是constencryptedEmail=localEncrypt(publickKey,email)。其中,const encryptedEmail是一个常量声明,用于存储加密后的邮箱信息,localEncrypt为一个函数名,这个函数应该被定义在代码的某个地方,或者作为一个库 / 模块的一部分被引入。这个函数接受两个参数(公钥和待加密数据),并返回加密数据,即加密后的邮箱信息。publicKey为一个变量,它应该包含用于加密的密钥信息,如公钥。Email为一个变量,包含要加密的邮箱信息。
[0128] 若业务代码将加密模块抽离出来之后,业务代码中对待加密数据(如邮箱信息)进行加密所涉及的具体代码可以是const encryptedEmail=encrypt(email)。其中,这行代码表示调用了一个名为encrypt的函数,并传入了一个参数email,即邮箱信息。函数encrypt可以对email进行加密处理,并将加密后的结果(即加密数据)存储在常量encryptedEmail中。可见,与未抽离出加密模块相比,一方面无需在业务代码中对加密信息进行硬编码,如无需指定上述未抽离加密模块所示例的代码中的publickKey,可以提高部署网页应用的加密方式和密钥信息的灵活性,也有利于满足用户针对网页数据的加密处理的个性化需求;另一方面,业务代码中无需涉及任何有关加密处理的代码,仅需要指定待加密数据即可通过加密模块对其进行加密处理,将加密体系与前端(业务侧)进行解耦,前端开发人员无需提前确定和在代码中部署加密信息,也无需关心加密方式和密钥信息,有利于提供前端的开发效率。
[0129] 在一种可能的实现方式中,客户端在通过加密模块基于加密方式和密钥信息对待加密数据进行加密处理的过程中,可以通过加密模块获取加密方式对应的代码块,如RSA对应的代码块。该代码块可以理解为某一种加密方式对应的第三方加密库(libraryJavaScript,libjs),可以包括用于实现特定加密算法和功能的代码,该代码为实现特定加密方式的第三方的JavaScript代码,可以是专业的密码学家或者安全团队开发的。通过加密模块(加密SDK)获取该加密方式对应的代码块的过程可以理解为客户端加载该代码块的JavaScript代码(JS代码)的过程。在加载完成之后,客户端可以运行代码块,基于密钥信息对待加密数据进行加密处理,具体地,客户端可以运行该代码块,并传入密钥信息,如公钥,对待加密数据进行加密处理,得到加密数据。
[0130] S402、客户端向部署有与触发操作关联的后台服务的服务器发送携带加密数据的网页请求。相应的,服务器接收客户端发送的携带加密数据的网页请求。
[0131] 在本申请实施例中,在客户端对待加密数据进行加密处理得到加密数据后,可以构建向服务器发送的HTTP请求,即该业务代码中可以包括用于构建HTTP请求的代码,可以用于构建携带该加密数据的请求,得到构建的网页请求。其中,对于网页应用来说,用户与网页进行交互,如输入文本、针对网页中的控件输入操作等,使得客户端向服务器发送的网页请求也可以称为应用程序编程接口(Application Programming Interface,API)请求。
[0132] 进一步地,在构建得到网页请求之后,客户端可以向部署有与该触发操作关联的后台服务的服务器发送该网页请求。需要说明的是,用户针对网页中不同控件输入的触发操作可以分别对应不同的后台服务,也即是对应部署有不同后台服务的服务器。例如,目标网页为一个在线商店的网页,可以将该目标网页所提供的不同功能,该功能也即是网页应用的业务逻辑,如商品详情、用户登录以及支付分别对应不同的业务逻辑,其后台服务可以映射到不同的后台服务器中,不同的后台服务器分别提供不同的后台服务。例如,商品详情服务器可以提供商品信息的查询和展示,也可以处理与商品相关的搜索、排序和筛选请求,并管理商品数据的存储和更新。登录服务器可以用于验证用户的身份(如用户名和密码),管理用户账户信息,如注册、更新密码等。支付服务器可以用于处理用户的支付请求,与支付网关进行交互,还可以验证支付信息的有效性,管理支付订单的状态和记录等。因此,客户端可以向部署有与该触发操作关联的后台服务的服务器发送该网页请求,如该触发操作为用户针对登录控件输入的触发操作,则客户端可以向登陆服务器发送携带加密数据的网页请求。
[0133] 需要说明的是,在本申请实施例中,以服务器部署有该触发操作关联的后台服务的服务器为例进行讲解,则该服务器可以接收客户端发送的携带加密数据的网页请求。
[0134] S403、服务器获取与目标网页关联的解密信息,并基于解密信息对加密数据进行解密处理,得到解密数据。
[0135] 在本申请实施例中,服务器在接收该网页请求后可以解析请求内容,得到该请求中携带的加密数据。进而,服务器可以获取与目标网页关联的解密信息,该解密信息可以是与目标网页关联的加密方式和解密密钥信息,加密方式是指通过特殊算法改变原有信息数据的方法,与客户端获取的加密信息中的加密方式相同,解密密钥信息是指用于对加密数据进行解密处理的密钥信息。在加密方式为非对称加密的情况下,该解密密钥信息可以为与加密处理所采用的密钥信息对应的密钥信息,例如密钥信息为某一个非对称加密算法的公钥,则解密密钥信息为该公钥对应的私钥。在服务器获取到解密信息后,可以基于解密信息对加密数据进行解密处理,得到解密数据,也即是解密得到客户端进行加密处理所涉及的敏感数据。
[0136] 在一种可能的实现方式中,服务器中可以部署有解密模块,服务器可以通过该解密模块获取包括加密方式和解密密钥信息的解密信息,并通过该解密模块基于加密方式和解密密钥信息对加密数据进行解密处理,得到解密数据。其中,解密模块可以是用于处理解密操作的SDK,即将解密逻辑封装到SDK中,该SDK可以是根据加密方式和解密密钥信息(私钥)编写的解密逻辑,也可以是调用其他解密库进行解密的解密逻辑,该SDK可以称为解密SDK。由此,后端开发人员也无需在后端代码对解密逻辑进行硬编码处理,使得后端代码与解密信息进行解耦,使得解密信息的部署和解密逻辑的部署均更加灵活。由此,系统的整个加密体系与前后端解耦,前后端的加密逻辑(解密逻辑)均封装为SDK来实现,可以在对业务代码零侵入的同时,满足了对加密信息 / 解密信息部署的灵活性。
[0137] 需要说明的是,由于一个网页可以提供不同的功能,例如上述在线商店网页,其不同的功能可以分别对应不同的后台服务器,不同的后台服务器所运行的后台服务的代码可以分别是基于不同的后端开发语言编写的,例如python、Java、php等开发语言。因此,针对不同的开发语言,可以分别在不同的服务器中部署对应开发语言的解密模块,用于分别实现解密逻辑。例如,若后台服务的开发语言为python,则部署的解密模块可以为pythonSDK,若后台服务的开发语言为Java,则部署的解密模块可以为Java SDK,若后台服务的开发语言为php,则部署的解密模块即为php SDK等,解密逻辑统一封装至各个SDK中。
[0138] 在一种实现方式中,服务器通过解密模块获取解密信息可以是从数据库中获取的,如从服务器的本地数据库中获取与目标网页关联的解密信息,也可以是从云端的数据获取到的解密信息,如基于目标网页从数据库中查询与该目标网页关联的解密信息。
[0139] 在另一种实现方式中,该服务器可以存储有包括有网页所需的配置信息的配置文件,服务器也可以通过解密模块从配置文件中获取该解密信息。
[0140] 在又一种实现方式中,该服务器还可以通过解密模块从环境变量中用于指定操作系统运行环境的参数中获取该解密信息。
[0141] 在再一种实现方式中,其他服务器中可以部署有加密服务,如图1所示的加密服务服务器103,服务器可以通过解密模块向部署有加密服务的其他服务器发送与该目标网页关联的解密信息获取请求,其他服务器响应于该服务器通过解密模块发送的请求,可以获取与该目标网页关联的解密信息,例如可以通过在数据库中查询、在配置文件中获取、在环境变量中获取、再转发给其他电子设备获取等方式,得到与该目标网页关联的解密信息。进一步地,服务器可以接收其他服务器发送的解密信息,并基于该解密信息所包括的解密方式和解密密钥信息进行解密处理,具体可以通过加载加密方式对应的解密库或者框架,解密库或者框架可以提供实现各种加密算法的工具和函数,以基于解密密钥信息进行解密处理,得到解密数据。进而,服务器可以将得到的解密数据返回至后端服务,即后端代码可以获取到解密SDK进行解密处理得到的解密数据,也可以理解为解密SDK将解密数据返回至后端业务侧。
[0142] S404、服务器根据解密数据执行对应的响应处理,得到操作响应信息。
[0143] 在本申请实施例中,服务器可以根据解密数据执行对应的响应处理,也即是服务器可以基于解密数据和网页请求执行相应的业务逻辑,得到执行结果,即该操作相应信息。示例性的,目标网页为一个包括表单的网页,用户可以基于该表单填写包括姓名、邮箱信息、手机号等信息,并基于该网页中提供的提交控件输入触发操作,客户端可以响应于携带诸如姓名、邮箱信息、手机号等待加密数据的触发操作,对待加密数据进行加密处理,并将携带加密处理得到的加密数据的网页请求发送至服务器。服务器在接收到该网页请求后,可以解析请求中的加密数据,获取与该目标网页关联的解密信息,并基于解密信息对该加密数据进行解密处理,得到解密数据,如姓名、邮箱信息、手机号等信息。进而,服务器可以根据相应的业务逻辑,如将解密处理得到的解密数据存储到数据库中,或者进行其他处理,如验证这些数据是否满足预设格式要求等。进而,服务器可以基于所执行的响应处理的执行结果生成操作响应信息,例如可以生成用于指示提交成功、验证通过等的操作响应信息。
[0144] S405、服务器将操作响应信息发送至客户端。相应的,客户端可以接收服务器响应于网页请求返回的操作响应信息。
[0145] 在本申请实施例中,服务器可以将生成的操作响应信息发送至客户端,客户端可以接收服务器发送的操作响应信息。其中,服务器生成的操作响应信息中还可以包含该目标网页的新的HTML内容,即新的代码文档(HTML文档),该HTML内容可以用于指示客户端在接收到该操作响应信息后,可以基于新的HTML内容更新该目标页面的用户界面,即基于新的HTML文档对目标网页进行渲染并输出,以反映用户针对目标网页输入的触发操作对应的变化。
[0146] 进一步地,用户可以继续与目标网页更新后的用户界面进行交互,例如查看所提交的数据、导航到其他网页或者进行其他操作,以进一步触发客户端向服务器再次发送网页请求。可以理解的是,客户端后续基于该目标网页接收到的操作,向服务器发送网页请求的流程可以参见上述流程,此处不再赘述。
[0147] 请一并参阅图5,图5是本申请实施例提供的一种客户端向服务器发送网页请求的时序示意图。图5以服务器与部署有加密服务的其他服务器进行交互,以获取与目标网页关联的解密信息为例进行讲解和绘制,加密模块可以为加密SDK(jsSDK),解密模块可以为解密SDK(如某一种后端开发语言的SDK,如php SDK)。如图5所示,首先,客户端可以响应于基于目标网页的触发操作,该触发操作携带待加密数据,该触发操作用于指示将待加密数据传输至服务器,即前端响应于触发操作或者请求,需要将敏感数据传递至后端。在向服务器发送网页请求之前,可以对待加密数据进行加密处理,具体可以通过加密模块(如jsSDK)对待加密数据进行加密处理,通过加密模块对待加密数据进行加密处理的过程可以称为将待加密数据传入jdSDK中部署的加密方法encrypt中,例如encrypt(待加密数据)以实现具体的加密处理的流程。
[0148] 具体的,客户端可以通过加密模块从指定对象的属性中获取加密方式和密钥信息,如从window对象下的transportSecret中读取加密方式和密钥信息(公钥),客户端通过加密模块从指定对象的属性中获取加密方式和密钥信息的过程可以称为在encrypt方法中,从window下获取transportSecret,并从中读取加密方式和公钥。进而,客户端可以通过加密模块获取加密方式对应的代码块,即获取该加密方式对应的libjs。进而,客户端可以通过加密模块运行该代码块(libjs),基于密钥信息对待加密数据进行加密处理,得到加密数据,也就是说加密模块可以在代码块(libjs)中的JavaScript代码加载完成后,调用libjs的代码块中的加密方法传入密钥信息(公钥)对待加密数据进行加密处理,得到加密数据。
[0149] 进一步地,客户端的加密模块可以将加密数据传递至业务代码中,以使业务代码生成携带该加密数据的网页请求,其中,将加密数据传递至业务代码可以称为将加密数据返回至业务侧。进而业务侧将该携带加密数据的网页请求发送至服务器,以向后端(服务器)发起请求。在请求到达后端(服务器)后,后端可以发起解密流程,也即是服务器接收到携带加密数据的网页请求后,可以通过解密模块,即某一种后端开发语言的SDK,如pythonsdk、javasdk、golangsdk等中的任一种,获取到网页请求中的加密数据,并向部署有加密服务的其他服务器发起解密信息的获取请求,以获取解密信息,即获取与目标网页关联的加密方式和解密密钥信息。其他服务器响应于该获取请求,可以采用不同方式获取解密信息,例如从数据库、环境变量、配置文件或者其他方式获取该与目标网页关联的解密信息。进而,其他服务器可以将包括加密方式和解密密钥信息的解密信息返回至服务器,具体可以返回至服务器中的解密模块。
[0150] 在服务器通过解密模块获取到与目标网页关联的加密方式和解密密钥信息(如私钥)之后,可以通过解密模块所编写的相关解密逻辑,或者调用解密库等方式,根据解密密钥信息对加密数据进行解密处理,得到解密数据。服务器中的部署有触发操作关联的后台服务的业务代码可以获取该解密数据,即该解密模块可以将解密数据传递至业务代码(业务侧,也可以称为后端服务),进而服务器可以根据解密数据执行对应的响应处理,得到操作响应信息。进而服务器可以将操作响应信息返回到客户端,也即是将respect返回到前端。
[0151] 请一并参阅图6,图6是本申请实施例提供的一种网页数据加密处理方法的系统架构图,如图6所示,客户端首次加载目标网页可参见图6中实线框所示,部署有中间层服务的软件的服务器可以响应于接收到客户端首次加载目标网页发送的加载请求,基于加密服务获取目标网页关联的加密方式和密钥信息,加密服务可以部署在服务器中,也可以部署在其他服务器上,通过加密服务可以获取到与该目标网页关联的加密方式和密钥信息,并将加密方式和密钥信息作为属性添加在指定对象的属性信息中。
[0152] 进一步地,客户端在加载目标网页完成后,可以基于与用户的交互发起网页请求,客户端后续发起网页请求可参见图6中虚线框所示。客户端可以基于目标网页与用户进行交互,目标网页可以提供多个业务,如图6所示的业务1、业务2…业务N,该业务可以理解为该目标网页提供的功能,也即是该目标网页所实现的业务逻辑,用户基于不同的功能输入触发操作,则客户端可以基于触发操作构建对应的网页请求,如图6所示的请求1、请求2…请求N等,在客户端生成网页请求之前,可以通过加密模块(如jsSDK)从指定对象的属性中获取加密方式和密钥信息。
[0153] 进而,客户端可以将通过加密模块进行加密处理得到的加密数据构建网页请求,即通过jsSDK实现encrypt方法。客户端在构建网页请求之后,可以将该网页请求发送至部署有对应后台服务的服务器,例如图6所示的后台服务1、后台服务2…后台服务N等。需要说明的是,在本申请实施例中,以服务器部署有中间层服务的软件,以及部署有诸如后台服务1、后台服务2以及后台服务N的软件为例进行讲解。服务器可以通过加密服务(如向部署有加密服务的其他服务器发送请求),获取与目标网页关联的解密信息,进而基于解密信息对加密数据进行解密处理,得到解密数据,并基于解密数据执行对应的响应处理,得到操作响应信息。最后服务器可以将该操作响应信息发送至客户端。由于将加密服务抽离出来,加密服务可以在该系统架构中充当生产者的角色,将加密方式和密钥信息分发至前端(客户端),并将加密方式和解密密钥信息分发至后端(服务器),消费者即为前端(客户端)和后端(服务器),由此,该系统架构也可以理解为前后端分离架构。
[0154] 在本申请中的一些实施例所提供的技术方案中,通过客户端在加载网页时,向服务器发送加载请求,服务器获取与客户端所加载的网页关联的加密信息,并基于加密信息生成加密代码,与该网页的业务代码生成代码文档后返回客户端,进而客户端可以基于业务代码加载该网页,并基于加密代码对从该网页中获取到的待加密数据进行加密处理。可见,与网页关联的加密信息是服务器接收到网页的加载请求后获取的,并不编写在该网页的业务代码中,该网页的加密信息与该网页的业务代码解耦,因此,与网页关联的加密方式和密钥信息不是固定在代码中的,可以在服务器获取的加密信息的数据源处对其进行切换和修改,有利于满足用户针对加密方式和密钥信息的个性化的需求,也使得加密方式和密钥信息的部署更为灵活。并且,在服务器获取的数据源处对加密信息进行修改,可以无需改动该网页的业务代码,也就无需重新部署整个网页应用,使得加密信息的修改更加便捷。
[0155] 请参阅图7,图7是本申请实施例提供了一种网页数据的加密处理方法的又一流程示意图,该网页数据的加密处理方法可由客户端和服务器交互实现。其中,客户端可以是图1所示的客户端设备101,服务器可以是图1所示的网页应用服务器102,该网页数据的加密处理方法可以包括以下步骤S701-S705,其中:
[0156] S701、客户端响应于目标网页的刷新操作,向服务器发送针对目标网页的第二加载请求。相应的,服务器接收客户端响应于目标网页的刷新操作发送的第二加载请求。
[0157] 在本申请实施例中,刷新操作是指触发重新加载该目标网页的操作,可以是客户端自动触发的,例如客户端按照预设时间间隔自动触发该刷新操作,也可以是接收用户针对该目标网页输入的刷新操作,如用户通过客户端安装的浏览器软件中的刷新控件触发的刷新操作。还可以是客户端输出用于提示用户刷新该目标网页的提示信息,用户基于提示信息输入的刷新操作,本申请对此不做限定。进而客户端可以向服务器发送针对目标网页的第二加载请求。该服务器与接收第一加载请求的服务器相同,是指Node.js服务器,即部署有中间层服务的软件的服务器。该第二加载请求为HTTP请求,用于再次请求获取该目标网页的内容。其中,客户端向服务器发送该第二加载请求的具体实现方式可以参见步骤S201中客户端向服务器发送第一加载请求的描述,此处不再赘述。在客户端向服务器发送第二加载请求后,服务器可以接收该第二加载请求。
[0158] 在一种可能的实现方式中,客户端在第一次加载出目标网页之后,即还没接收到刷新操作时,可以向部署有后台服务的服务器发送携带该目标网页的网页信息的连接建立请求,部署有后台服务的服务器可以接收该连接建立请求,并响应于该连接建立请求,向客户端发送连接响应信息,该连接响应信息用于指示客户端和服务器完成通信连接的建立。其中,服务器和客户端所建立的通信连接可以是基于WebSocket通信协议的通信连接,该通信协议允许在客户端和服务器之间建立一个持久的通信连接,并进行全双工通信,即双方都可以在任何时候向对方发送数据,进而服务器和客户端可以基于该通信连接发送消息。
[0159] 具体地,服务器可以创建Websocket服务,并监测客户端的连接请求,其中,服务器创建Websocket服务是指在服务器上运行一个应用程序或脚本,该程序使用Websocket协议来监测来自客户端的连接请求,如监测特定端口,等待客户端的连接请求。进而,客户端可以创建Websocket连接,并连接到服务器的Websocket服务。其中,客户端创建Websocket连接是指在客户端上运行Javascript代码,以向服务器发送连接建立请求,并接收服务器返回的连接响应信息,以建立与服务器的通信连接,即完成连接到服务器的Websocket服务。
[0160] 进而,服务器在检测到与目标网页关联的加密信息发生更新的情况下,向客户端发送刷新指示信息,该刷新指示信息用于指示客户端触发目标网页的刷新操作,客户端可以监测前端发送的消息,在接收到刷新指示信息后,可以触发重新加载该目标网页。由于加密方式和密钥信息并非编写在业务代码中,而是服务器从数据源获取到的,则当数据源发生改变,例如数据源是数据库,数据库中存储的与目标网页关联的加密方式从RSA2048切换为KM-2,即数据库中的加密方式发生更新。再例如,数据源是配置文件,则可以在配置文件中目标网页关联的加密方式和密钥信息可以被用户修改,则配置文件中的加密信息发生更新。这些情况下,服务器均向客户端发送刷新指示信息,通知客户端刷新该目标网页。
[0161] 其中,刷新指示信息可以是"refresh”消息,可以是服务器调用发送"refresh”消息的函数向客户端发送的。需要说明的是,服务器可以与多个加载出该目标网页的客户端建立通信连接,服务器在检测到与目标网页关联的加密信息发生更新的情况下,向所有建立通信连接的客户端发送刷新指示信息,如"refresh”消息,以指示客户端端触发目标网页的刷新操作,即告诉前端需要刷新页面。进而,客户端在接收到刷新指示信息后,可以触发刷新操作,重新加载该目标网页。
[0162] 在一些实施例中,服务器向客户端发送刷新指示信息之外,还可以发送用于更新用户界面的配置信息,如用于加载目标网页的用户界面的业务代码,客户端可以基于该配置信息更新该目标页面的用户界面,以确保前端展示的内容与服务器端的变更保持同步。
[0163] 在一种可能的实现方式中,若加密信息中的加密方式或者密钥信息(公钥和私钥)需要变更,则可以在服务器获取加密方式、公钥和私钥所依赖的数据源进行修改,如在加密服务的数据源变更加密方式或密钥信息,例如依赖的数据源为数据库,则可以变更数据库中与目标网页关联的methed和public_key来修改加密方式或者公钥,再例如,依赖的数据源为配置文件,则可以修改配置文件中的methed和public_key来进行修改。在修改完成之后,服务器可以检测到加密信息发生更新,并向客户端发送刷新指示信息。
[0164] 其中,加密信息发生更新可以是用户对服务器获取加密信息依赖的数据源进行修改实现的,用户在完成修改后,可以触发通知服务器该加密方式、密钥信息(公钥和私钥)发生更新。服务器也可以周期性地对各个网页关联的加密信息进行比对,确定是否有加密信息发生更新。
[0165] 进一步地,在客户端接收到刷新指示信息后,可以触发目标网页的刷新操作,进而向服务器发送针对目标网页的第二加载请求,以基于服务器返回的代码文档重新加载该目标网页。
[0166] S702、服务器响应于第二加载请求,获取与目标网页关联的更新加密信息和业务代码。
[0167] S703、服务器根据更新加密信息构建更新加密代码,并根据更新加密代码和业务代码生成目标网页的更新代码文档。
[0168] S704、服务器将携带更新代码文档的更新响应信息发送至客户端。相应的,客户端接收服务器响应于第二加载请求返回的更新响应信息。
[0169] S705、客户端基于业务代码重新加载目标网页,并基于更新加密代码对从重新加载后的目标网页获取到的待加密数据进行加密处理。
[0170] 其中,步骤S702-步骤S705中服务器响应于目标网页的第二加载请求,并返回客户端更新响应信息,客户端基于业务代码加载目标网页,并基于加密代码对待加密数据进行加密处理的原理可参见步骤S202-步骤S205的具体描述,此处不再赘述。需要说明的是,在本实施例中,服务器获取到的加密信息是更新加密信息,与上一次加载目标网页时获取到的加密信息相比,其所包括的加密方式和密钥信息中至少一项发生了更新。客户端设备基于更新加密代码从重新加载后的目标网页获取到的待加密数据进行加密处理可以是指客户端可以重新加载出该目标网页,并基于重新加载出的目标网页与用户进行交互,并在需要向服务器发送网页请求时将交互中产生的敏感数据进行加密处理,此时加密处理所采用的是更新加密信息中的加密方式和密钥信息,并进一步向服务器发送携带加密处理后的数据的网页请求。
[0171] 由此,在服务器获取加密信息的数据源处修改加密信息之后,刷新该目标网页后所进行加密处理的加密方式和密钥信息为新的加密方式或者新的密钥信息。在对加密信息进行修改的过程中,业务代码并不需要任何的改动,实现了对业务代码零侵入,加密方式和密钥信息(公钥和私钥)的改动无需通知业务侧,即无需改动业务代码的前提下支持多种加密方式。特别是针对私有云场景下不同的用户想要加密方式或者密钥信息不一致的情形,可以通过同一套代码实现一个网页应用分别对应多种加密方式,以应对同一用户或不同用户多样化的加密需求,降低更换加密方式或者密钥信息的成本。
[0172] 并且,在修改加密信息的过程中,无需重新部署该网页应用,也即是不会出现因为重新部署该网页应用而无法访问该目标网页的情况,这种更换加密信息的方式可以在该网页应用运行时进行实时动态切换,即在系统运行时,不中断业务的前提下动态切换系统的加密方式或者密钥信息,将前后端的加密逻辑统一封装为SDK来实现,有利于实现对业务代码零侵入的同时做到了网页应用运行时动态修改系统中的加密信息,提高网页应用的稳定性。
[0173] 在本申请中的一些实施例所提供的技术方案中,通过客户端在加载网页时,向服务器发送加载请求,服务器获取与客户端所加载的网页关联的加密信息,并基于加密信息生成加密代码,与该网页的业务代码生成代码文档后返回客户端,进而客户端可以基于业务代码加载该网页,并基于加密代码对从该网页中获取到的待加密数据进行加密处理。可见,与网页关联的加密信息是服务器接收到网页的加载请求后获取的,并不编写在该网页的业务代码中,该网页的加密信息与该网页的业务代码解耦,因此,与网页关联的加密方式和密钥信息不是固定在代码中的,可以在服务器获取的加密信息的数据源处对其进行切换和修改,有利于满足用户针对加密方式和密钥信息的个性化的需求,也使得加密方式和密钥信息的部署更为灵活。并且,在服务器获取的数据源处对加密信息进行修改,可以无需改动该网页的业务代码,也就无需重新部署整个网页应用,使得加密信息的修改更加便捷。
[0174] 上述详细阐述了本申请实施例的方法,为了便于更好地实施本申请实施例的上述方案,相应地,下面提供了本申请实施例的装置。
[0175] 请参阅图8,图8是本申请实施例提供的一种网页数据的加密处理装置的结构示意图,该网页数据的加密处理装置80应用于客户端,可以用于执行图2、图4和图7所示的网页数据的加密处理方法中的相应步骤。该网页数据的加密处理装置80包括如下单元:
[0176] 发送单元801,用于响应于目标网页的加载操作,向服务器发送针对所述目标网页的第一加载请求;
[0177] 接收单元802,用于接收所述服务器响应于所述第一加载请求返回的响应信息,所述响应信息携带所述目标网页的代码文档,所述代码文档是所述服务器根据所述目标网页对应的加密代码和业务代码生成的,所述加密代码是根据所述目标网页关联的加密信息生成的;
[0178] 处理单元803,用于基于所述业务代码加载所述目标网页,并基于所述加密代码对从所述目标网页获取到的待加密数据进行加密处理。
[0179] 在一种可能的实现方式中,所述处理单元803,用于基于所述加密代码对从所述目标网页获取到的待加密数据进行加密处理,具体用于:
[0180] 响应于从所述目标网页接收到的携带所述待加密数据的触发操作,基于所述加密信息对所述待加密数据进行加密处理,得到加密数据;
[0181] 所述发送单元801,还用于向部署有与所述触发操作关联的后台服务的服务器发送携带所述加密数据的网页请求;
[0182] 所述接收单元802,还用于接收所述服务器响应于所述网页请求返回的操作响应信息,所述操作响应信息是所述服务器基于所述目标网页关联的解密信息对所述加密数据进行解密处理得到解密数据之后,根据所述解密数据执行对应的响应处理得到的。
[0183] 在一种可能的实现方式中,所述加密信息包括与所述目标网页关联的加密方式和密钥信息;所述业务代码中包括加密模块的代码;所述处理单元803,用于基于所述加密信息对所述待加密数据进行加密处理,得到加密数据,具体用于:
[0184] 通过所述加密模块获取所述加密方式和所述密钥信息;
[0185] 通过所述加密模块基于所述加密方式和所述密钥信息对所述待加密数据进行加密处理,得到所述加密数据。
[0186] 在一种可能的实现方式中,所述加密代码是所述服务器将加密配置信息作为属性添加在指定对象的属性信息中得到的,所述加密配置信息是根据所述加密方式、所述密钥信息和预设格式的配置信息得到的;
[0187] 所述通过所述加密模块获取所述加密方式和所述密钥信息之前,所述处理单元803,还用于基于所述加密代码将所述指定对象的属性设置为所述加密方式和所述密钥信息;
[0188] 所述处理单元803,用于通过所述加密模块获取所述加密方式和所述密钥信息,具体用于:
[0189] 通过所述加密模块从所述指定对象的属性中获取所述加密方式和所述密钥信息。
[0190] 在一种可能的实现方式中,所述处理单元803,用于通过所述加密模块基于所述加密方式和所述密钥信息对所述待加密数据进行加密处理,得到所述加密数据,具体用于:
[0191] 通过所述加密模块获取所述加密方式对应的代码块;
[0192] 运行所述代码块,基于所述密钥信息对所述待加密数据进行加密处理,得到所述加密数据。
[0193] 在一种可能的实现方式中,所述发送单元801,还用于响应于所述目标网页的刷新操作,向所述服务器发送针对所述目标网页的第二加载请求;
[0194] 所述接收单元802,还用于接收所述服务器响应于所述第二加载请求返回的更新响应信息,所述更新响应信息携带所述目标网页的更新代码文档,所述更新代码文档是所述服务器根据所述目标网页对应的更新加密代码和所述业务代码生成的,所述更新加密代码是根据所述目标网页关联的更新加密信息生成的;
[0195] 所述处理单元803,还用于基于所述业务代码重新加载所述目标网页,并基于所述更新加密代码对从重新加载后的目标网页获取到的待加密数据进行加密处理。
[0196] 在一种可能的实现方式中,所述发送单元801,还用于向所述服务器发送携带所述目标网页的网页信息的连接建立请求;
[0197] 所述接收单元802,还用于接收所述服务器响应于所述连接建立请求返回的连接响应信息,所述连接响应信息用于指示所述客户端和所述服务器之间完成通信连接的建立;
[0198] 所述接收单元802,还用于通过所述通信连接接收所述服务器发送的刷新指示信息,所述刷新指示信息用于指示所述客户端触发所述目标网页的刷新操作;
[0199] 其中,所述刷新指示信息是所述服务器在检测到与所述目标网页关联的加密信息发生更新的情况下,通过所述通信连接向所述客户端发送的。
[0200] 根据本申请的一个实施例,图2、图4和图7所示的方法所涉及的步骤可以是由图8所示的网页数据的加密处理装置中的各个单元执行的。例如,图3所示的步骤S201由图8所示的发送单元801来执行,步骤S204由图8所示的接收单元802步骤来执行,步骤S205由图8所示的处理单元803步骤来执行。再例如,图4所示的步骤S401由图8所示的处理单元803来执行,步骤S402由图8所示的发送单元801来执行,步骤S405由图8所示的接收单元802来执行。再例如,图7所示的步骤S701由图8所示的发送单元801来执行,步骤S704由图8所示的接受单元801来执行,步骤S705由图8所示的处理单元803来执行.
[0201] 根据本申请的一个实施例,图8所示的网页数据的加密处理装置80中的各个单元可以分别或全部合并为一个或若干个另外的单元来构成,或者其中的某个(些)单元还可以再拆分为功能上更小的多个单元来构成,这可以实现同样的操作,而不影响本申请的实施例的技术效果的实现。上述单元是基于逻辑功能划分的,在实际应用中,一个单元的功能也可以由多个单元来实现,或者多个单元的功能由一个单元实现。在本申请的其它实施例中,该网页数据的加密处理装置80也可以包括其它单元,在实际应用中,这些功能也可以由其它单元协助实现,并且可以由多个单元协作实现。根据本申请的另一个实施例,可以通过在包括例如中央处理单元(CPU)、随机存取存储介质(RAM)、只读存储介质(ROM)等处理元件和存储元件的通用计算机的通用计算设备上运行能够执行如图2、图4和图7中所示的相应方法所涉及的各步骤的计算机程序(包括程序代码),来构造如图8中所示的网页数据的加密处理装置80,以及来实现本申请实施例的网页数据的加密处理方法。计算机程序可以记载于例如计算机可读存储介质上,并通过计算机可读存储介质装载于图1所示网页数据的加密处理系统的客户端设备101中,并在其中运行。
[0202] 请参阅图9,图9是本申请实施例提供的另一种网页数据的加密处理装置的结构示意图,该网页数据的加密处理装置90应用于服务器,可以用于执行图2、图4和图7所示的网页数据的加密处理方法中的相应步骤。该网页数据的加密处理装置90包括如下单元:
[0203] 获取单元901,用于响应于接收到客户端发送的针对目标网页的第一加载请求,获取与所述目标网页关联的加密信息和业务代码;
[0204] 处理单元902,用于根据所述加密信息构建加密代码,并根据所述加密代码和所述业务代码生成所述目标网页的代码文档;
[0205] 发送单元903,用于将携带所述代码文档的响应信息发送至所述客户端,所述响应信息用于指示所述客户端基于所述业务代码加载所述目标网页,并基于所述加密代码对从所述目标网页获取到的待加密数据进行加密处理。
[0206] 在一种可能的实现方式中,所述加密信息包括与所述目标网页关联的加密方式和密钥信息,所述处理单元902,用于根据所述加密信息构建加密代码,具体用于:
[0207] 获取预设格式的配置信息,并将所述加密方式和所述密钥信息按照所述预设格式填入所述配置信息中,得到加密配置信息;
[0208] 将所述加密配置信息作为属性添加在指定对象的属性信息中,得到所述加密代码,所述加密代码用于指示所述客户端将所述指定对象的属性设置为所述加密信息和所述密钥信息。
[0209] 在一种可能的实现方式中,所述处理单元902,用于根据所述加密代码和所述业务代码生成所述目标网页的代码文档,具体用于:
[0210] 按照所述业务代码所采用的指定开发语言的开发格式,将所述加密代码添加在所述业务代码中;
[0211] 基于添加后的业务代码生成所述代码文档。
[0212] 在一种可能的实现方式中,所述网页数据的加密处理装置还包括接收单元904,用于接收所述客户端发送的携带加密数据的网页请求,所述网页请求是所述客户端基于所述加密信息对所述待加密数据进行加密处理,得到加密数据之后发送的;
[0213] 所述处理单元902,还用于获取与所述目标网页关联的解密信息,并基于所述解密信息对所述加密数据进行解密处理,得到解密数据;
[0214] 所述处理单元902,还用于根据所述解密数据执行对应的响应处理,得到操作响应信息,并将所述操作响应信息发送至所述客户端。
[0215] 在一种可能的实现方式中,所述处理单元902,用于获取与所述目标网页关联的解密信息,并基于所述解密信息对所述加密数据进行解密处理,得到解密数据,具体用于:
[0216] 通过部署在所述服务器中的解密模块获取所述解密信息,所述解密信息包括与所述目标网页关联的加密方式和解密密钥信息;
[0217] 通过所述解密模块基于所述加密方式和所述解密密钥信息对所述加密数据进行解密处理,得到所述解密数据。
[0218] 在一种可能的实现方式中,所述接收单元904,还用于接收所述客户端响应于所述目标网页的刷新操作发送的第二加载请求;
[0219] 所述处理单元902,用于响应于所述第二加载请求,获取与所述目标网页关联的更新加密信息和所述业务代码;
[0220] 所述处理单元902,还用于根据所述更新加密信息构建更新加密代码,并根据所述更新加密代码和所述业务代码生成所述目标网页的更新代码文档;
[0221] 所述发送单元903,用于将携带所述更新代码文档的更新响应信息发送至所述客户端,所述更新响应信息用于指示所述客户端基于所述业务代码重新加载所述目标网页,并基于所述更新加密代码对从重新加载后的目标网页获取到的待加密数据进行加密处理。
[0222] 在一种可能的实现方式中,所述接收单元904,还用于接收所述客户端发送的携带所述目标网页的网页信息的连接建立请求;
[0223] 所述发送单元903于响应于所述连接建立请求,向所述客户端发送连接响应信息,所述连接响应信息用于指示所述客户端和所述服务器完成通信连接的建立;
[0224] 所述发送单元903,还用于在检测到与所述目标网页关联的加密信息发生更新的情况下,向所述客户端发送刷新指示信息,所述刷新指示信息用于指示所述客户端触发所述目标网页的刷新操作。
[0225] 根据本申请的一个实施例,图2、图4和图7所示的方法所涉及的步骤可以是由图9所示的网页数据的加密处理装置中的各个单元执行的。例如,图2所示的步骤S202由图9所示的获取单元901来执行,步骤S203由图9所示的处理单元902来执行,步骤S204由图9所示的发送单元903来执行。再例如,图4所示的步骤S402由图9所示的接收单元904来执行,步骤S403-S405由图9所示的处理单元904来执行。再例如,图7所示的步骤S701由图9所示的接收单元902来执行,步骤S702-S703由图9所示的处理单元902来执行,步骤S704由图9所示的发送单元903来执行。
[0226] 根据本申请的一个实施例,图9所示的网页数据的加密处理装置90中的各个单元可以分别或全部合并为一个或若干个另外的单元来构成,或者其中的某个(些)单元还可以再拆分为功能上更小的多个单元来构成,这可以实现同样的操作,而不影响本申请的实施例的技术效果的实现。上述单元是基于逻辑功能划分的,在实际应用中,一个单元的功能也可以由多个单元来实现,或者多个单元的功能由一个单元实现。在本申请的其它实施例中,该网页数据的加密处理装置90也可以包括其它单元,在实际应用中,这些功能也可以由其它单元协助实现,并且可以由多个单元协作实现。根据本申请的另一个实施例,可以通过在包括例如中央处理单元(CPU)、随机存取存储介质(RAM)、只读存储介质(ROM)等处理元件和存储元件的通用计算机的通用计算设备上运行能够执行如图2、图4和图7中所示的相应方法所涉及的各步骤的计算机程序(包括程序代码),来构造如图9中所示的网页数据的加密处理装置90,以及来实现本申请实施例的网页数据的加密处理方法。计算机程序可以记载于例如计算机可读存储介质上,并通过计算机可读存储介质装载于图1所示网页数据的加密处理系统的网页应用服务器102中,并在其中运行。
[0227] 基于上述网页数据的加密处理方法实施例的描述,本申请实施例还公开一种电子设备,请参阅图10,该电子设备100至少可包括处理器1001、输入设备1002、输出设备1003以及存储器1004。其中,电子设备100内的处理器1001、输入设备1002、输出设备1003以及存储器1004可通过总线或其他方式连接。
[0228] 上述存储器1004是电子设备100中的记忆设备,用于存放程序和数据。可以理解的是,此处的存储器1004既可以包括网页数据的加密处理设备的内置存储介质,当然也可以包括电子设备100支持的扩展存储介质。存储器1004提供存储空间,该存储空间存储了电子设备100的操作系统。并且,在该存储空间中还存放计算机程序(包括程序代码)。需要说明的是,此处的计算机存储介质可以是高速RAM存储器;可选的,还可以是至少一个远离前述处理器的计算机存储介质、上述处理器可以称为中央处理单元(Central ProcessingUnit,CPU),是网页数据的加密处理设备的核心以及控制中心,用于运行上述存储器1004中存储的计算机程序。
[0229] 在一种实施方式中,可由处理器1001加载并执行存储器1004中存放的计算机程序,以实现上述有关网页数据的加密处理方法实施例中的方法的相应步骤;具体的,上述处理器1001加载并执行存储器1004中存放的计算机程序,用于:
[0230] 响应于目标网页的加载操作,向服务器发送针对所述目标网页的第一加载请求;
[0231] 接收所述服务器响应于所述第一加载请求返回的响应信息,所述响应信息携带所述目标网页的代码文档,所述代码文档是所述服务器根据所述目标网页对应的加密代码和业务代码生成的,所述加密代码是根据所述目标网页关联的加密信息生成的;
[0232] 基于所述业务代码加载所述目标网页,并基于所述加密代码对从所述目标网页获取到的待加密数据进行加密处理。
[0233] 在一种可能的实现方式中,所述处理器1001加载并执行存储器1004中存放的计算机程序,用于基于所述加密代码对从所述目标网页获取到的待加密数据进行加密处理,具体用于:
[0234] 响应于从所述目标网页接收到的携带所述待加密数据的触发操作,基于所述加密信息对所述待加密数据进行加密处理,得到加密数据;
[0235] 所述方法还包括:
[0236] 向部署有与所述触发操作关联的后台服务的服务器发送携带所述加密数据的网页请求;
[0237] 接收所述服务器响应于所述网页请求返回的操作响应信息,所述操作响应信息是所述服务器基于所述目标网页关联的解密信息对所述加密数据进行解密处理得到解密数据之后,根据所述解密数据执行对应的响应处理得到的。
[0238] 在一种可能的实现方式中,所述加密信息包括与所述目标网页关联的加密方式和密钥信息;所述业务代码中包括加密模块的代码;所述处理器1001加载并执行存储器1004中存放的计算机程序,用于基于所述加密信息对所述待加密数据进行加密处理,得到加密数据,具体用于:
[0239] 通过所述加密模块获取所述加密方式和所述密钥信息;
[0240] 通过所述加密模块基于所述加密方式和所述密钥信息对所述待加密数据进行加密处理,得到所述加密数据。
[0241] 在一种可能的实现方式中,所述加密代码是所述服务器将加密配置信息作为属性添加在指定对象的属性信息中得到的,所述加密配置信息是根据所述加密方式、所述密钥信息和预设格式的配置信息得到的;
[0242] 所述处理器1001加载并执行存储器1004中存放的计算机程序,还用于基于所述加密代码将所述指定对象的属性设置为所述加密方式和所述密钥信息;
[0243] 所述处理器1001加载并执行存储器1004中存放的计算机程序,用于通过所述加密模块获取所述加密方式和所述密钥信息,具体用于:
[0244] 通过所述加密模块从所述指定对象的属性中获取所述加密方式和所述密钥信息。
[0245] 在一种可能的实现方式中,所述处理器1001加载并执行存储器1004中存放的计算机程序,用于通过所述加密模块基于所述加密方式和所述密钥信息对所述待加密数据进行加密处理,得到所述加密数据,具体用于:
[0246] 通过所述加密模块获取所述加密方式对应的代码块;
[0247] 运行所述代码块,基于所述密钥信息对所述待加密数据进行加密处理,得到所述加密数据。
[0248] 在一种可能的实现方式中,所述处理器1001加载并执行存储器1004中存放的计算机程序,还用于:
[0249] 响应于所述目标网页的刷新操作,向所述服务器发送针对所述目标网页的第二加载请求;
[0250] 接收所述服务器响应于所述第二加载请求返回的更新响应信息,所述更新响应信息携带所述目标网页的更新代码文档,所述更新代码文档是所述服务器根据所述目标网页对应的更新加密代码和所述业务代码生成的,所述更新加密代码是根据所述目标网页关联的更新加密信息生成的;
[0251] 基于所述业务代码重新加载所述目标网页,并基于所述更新加密代码对从重新加载后的目标网页获取到的待加密数据进行加密处理。
[0252] 在一种可能的实现方式中,所述处理器1001加载并执行存储器1004中存放的计算机程序,还用于:
[0253] 向所述服务器发送携带所述目标网页的网页信息的连接建立请求;
[0254] 接收所述服务器响应于所述连接建立请求返回的连接响应信息,所述连接响应信息用于指示所述客户端和所述服务器之间完成通信连接的建立;
[0255] 所述响应于所述目标网页的刷新操作,向所述服务器发送针对所述目标网页的第二加载请求之前,所述方法还包括:
[0256] 通过所述通信连接接收所述服务器发送的刷新指示信息,所述刷新指示信息用于指示所述客户端触发所述目标网页的刷新操作;
[0257] 其中,所述刷新指示信息是所述服务器在检测到与所述目标网页关联的加密信息发生更新的情况下,通过所述通信连接向所述客户端发送的。
[0258] 在一种可能的实现方式中,可由处理器1001加载并执行存储器1004中存放的计算机程序,以实现上述有关另一种网页数据的加密处理方法实施例中的相应步骤;具体的,上述处理器1001加载并执行存储器1004中存放的计算机程序,用于:
[0259] 响应于接收到客户端发送的针对目标网页的第一加载请求,获取与所述目标网页关联的加密信息和业务代码;
[0260] 根据所述加密信息构建加密代码,并根据所述加密代码和所述业务代码生成所述目标网页的代码文档;
[0261] 将携带所述代码文档的响应信息发送至所述客户端,所述响应信息用于指示所述客户端基于所述业务代码加载所述目标网页,并基于所述加密代码对从所述目标网页获取到的待加密数据进行加密处理。
[0262] 在一种可能的实现方式中,所述加密信息包括与所述目标网页关联的加密方式和密钥信息,所述处理器1001加载并执行存储器1004中存放的计算机程序,用于根据所述加密信息构建加密代码,具体用于:
[0263] 获取预设格式的配置信息,并将所述加密方式和所述密钥信息按照所述预设格式填入所述配置信息中,得到加密配置信息;
[0264] 将所述加密配置信息作为属性添加在指定对象的属性信息中,得到所述加密代码,所述加密代码用于指示所述客户端将所述指定对象的属性设置为所述加密信息和所述密钥信息。
[0265] 在一种可能的实现方式中,所述处理器1001加载并执行存储器1004中存放的计算机程序,用于根据所述加密代码和所述业务代码生成所述目标网页的代码文档,具体用于:
[0266] 按照所述业务代码所采用的指定开发语言的开发格式,将所述加密代码添加在所述业务代码中;
[0267] 基于添加后的业务代码生成所述代码文档。
[0268] 在一种可能的实现方式中,所述处理器1001加载并执行存储器1004中存放的计算机程序,还用于:
[0269] 接收所述客户端发送的携带加密数据的网页请求,所述网页请求是所述客户端基于所述加密信息对所述待加密数据进行加密处理,得到加密数据之后发送的;
[0270] 获取与所述目标网页关联的解密信息,并基于所述解密信息对所述加密数据进行解密处理,得到解密数据;
[0271] 根据所述解密数据执行对应的响应处理,得到操作响应信息,并将所述操作响应信息发送至所述客户端。
[0272] 在一种可能的实现方式中,所述处理器1001加载并执行存储器1004中存放的计算机程序,用于获取与所述目标网页关联的解密信息,并基于所述解密信息对所述加密数据进行解密处理,得到解密数据,具体用于:
[0273] 通过部署在所述服务器中的解密模块获取所述解密信息,所述解密信息包括与所述目标网页关联的加密方式和解密密钥信息;
[0274] 通过所述解密模块基于所述加密方式和所述解密密钥信息对所述加密数据进行解密处理,得到所述解密数据。
[0275] 在一种可能的实现方式中,所述处理器1001加载并执行存储器1004中存放的计算机程序,还用于:
[0276] 接收所述客户端响应于所述目标网页的刷新操作发送的第二加载请求;
[0277] 响应于所述第二加载请求,获取与所述目标网页关联的更新加密信息和所述业务代码;
[0278] 根据所述更新加密信息构建更新加密代码,并根据所述更新加密代码和所述业务代码生成所述目标网页的更新代码文档;
[0279] 将携带所述更新代码文档的更新响应信息发送至所述客户端,所述更新响应信息用于指示所述客户端基于所述业务代码重新加载所述目标网页,并基于所述更新加密代码对从重新加载后的目标网页获取到的待加密数据进行加密处理。
[0280] 在一种可能的实现方式中,所述处理器1001加载并执行存储器1004中存放的计算机程序,还用于:
[0281] 接收所述客户端发送的携带所述目标网页的网页信息的连接建立请求;
[0282] 响应于所述连接建立请求,向所述客户端发送连接响应信息,所述连接响应信息用于指示所述客户端和所述服务器完成通信连接的建立;
[0283] 在检测到与所述目标网页关联的加密信息发生更新的情况下,向所述客户端发送刷新指示信息,所述刷新指示信息用于指示所述客户端触发所述目标网页的刷新操作。
[0284] 应当理解,在本申请实施例中,所称处理器1001可以是中央处理单元(CentralProcessing Unit,CPU),该处理器1001还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific IntegratedCircuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
[0285] 本申请实施例中提供一种计算机可读存储介质,上述计算机可读存储介质存储有计算机程序,上述计算机程序包括程序指令,上述程序指令被处理器执行时,可执行上述所有实施例中所执行的步骤。
[0286] 本申请实施例还提供一种计算机程序产品或计算机程序,计算机程序产品或计算机程序包括计算机指令,计算机指令存储在计算机可读存储介质中,计算机指令被计算机设备的处理器执行时,执行上述所有实施例中的方法。
[0287] 本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,上述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,上述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random AccessMemory,RAM)等。
[0288] 以上所揭露的仅为本发明一种较佳实施例而已,当然不能以此来限定本发明之权利范围,本领域普通技术人员可以理解实现上述实施例的全部或部分流程,并依本发明权利要求所作的等同变化,仍属于发明所涵盖的范围。
[0289] 另外特别需要说明的是,当本申请以上实施例运用到具体产品或技术中时,若需要获取用户的数据,则需要获得该用户许可或者同意,且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准。< / script>
Claims
1. A method for encrypting webpage data, characterized in that, Applied to the client side, including: In response to the loading operation of the target webpage, a first loading request for the target webpage is sent to the server; The server receives a response to the first loading request. The response carries the code document of the target webpage. The code document is generated by the server based on the encrypted code and business code corresponding to the target webpage. The encrypted code is generated based on the encrypted information associated with the target webpage. The target webpage is loaded based on the business code, and the data to be encrypted obtained from the target webpage is encrypted based on the encryption code.
2. The method according to claim 1, characterized in that, The encryption process of the data to be encrypted obtained from the target webpage based on the encryption code includes: In response to a trigger operation received from the target webpage carrying the data to be encrypted, the data to be encrypted is encrypted based on the encryption information to obtain encrypted data; The method further includes: Send a webpage request carrying the encrypted data to a server that has a background service associated with the triggering operation; The server receives operation response information returned in response to the webpage request. The operation response information is obtained by the server decrypting the encrypted data based on the decryption information associated with the target webpage, and then performing corresponding response processing based on the decrypted data.
3. The method according to claim 2, characterized in that, The encrypted information includes the encryption method and key information associated with the target webpage; the business code includes the code of the encryption module; The step of encrypting the data to be encrypted based on the encryption information to obtain encrypted data includes: The encryption module obtains the encryption method and the key information. The encryption module encrypts the data to be encrypted based on the encryption method and the key information to obtain the encrypted data.
4. The method according to claim 3, characterized in that, The encryption code is obtained by the server adding the encryption configuration information as an attribute to the attribute information of a specified object. The encryption configuration information is obtained based on the encryption method, the key information, and the configuration information in a preset format. Before obtaining the encryption method and the key information through the encryption module, the method further includes: Based on the encryption code, the attributes of the specified object are set to the encryption method and the key information; The step of obtaining the encryption method and the key information through the encryption module includes: The encryption module obtains the encryption method and the key information from the attributes of the specified object.
5. The method according to claim 3, characterized in that, The process of encrypting the data to be encrypted using the encryption module based on the encryption method and the key information to obtain the encrypted data includes: The encryption module obtains the code block corresponding to the encryption method. The code block is executed to encrypt the data to be encrypted based on the key information, thereby obtaining the encrypted data.
6. The method according to claim 1, characterized in that, The method further includes: In response to a refresh operation on the target webpage, a second loading request for the target webpage is sent to the server; The server receives an update response information returned in response to the second loading request. The update response information carries an update code document for the target webpage. The update code document is generated by the server based on the update encryption code corresponding to the target webpage and the business code. The update encryption code is generated based on the update encryption information associated with the target webpage. The target webpage is reloaded based on the business code, and the data to be encrypted obtained from the reloaded target webpage is encrypted based on the updated encryption code.
7. The method according to claim 6, characterized in that, After loading the target webpage based on the business code, the method further includes: Send a connection establishment request carrying webpage information of the target webpage to the server; The client receives connection response information returned by the server in response to the connection establishment request, and the connection response information is used to indicate that a communication connection has been established between the client and the server. Before sending a second loading request for the target webpage to the server in response to a refresh operation of the target webpage, the method further includes: The client receives refresh instruction information sent by the server through the communication connection. The refresh instruction information is used to instruct the client to trigger a refresh operation on the target webpage. The refresh instruction information is sent by the server to the client through the communication connection when it detects an update to the encrypted information associated with the target webpage.
8. A method for encrypting webpage data, characterized in that, Applied to servers, including: In response to receiving a first loading request for a target webpage from a client, the system obtains encrypted information and business code associated with the target webpage. Based on the encrypted information, encrypted code is constructed, and based on the encrypted code and the business code, the code document of the target webpage is generated; The response information carrying the code document is sent to the client. The response information is used to instruct the client to load the target webpage based on the business code and to encrypt the data to be encrypted obtained from the target webpage based on the encryption code.
9. The method according to claim 8, characterized in that, The encryption information includes encryption method and key information associated with the target webpage, and the step of constructing encryption code based on the encryption information includes: Obtain configuration information in a preset format, and fill the encryption method and the key information into the configuration information according to the preset format to obtain encryption configuration information; The encryption configuration information is added as an attribute to the attribute information of a specified object to obtain the encryption code. The encryption code is used to instruct the client to set the attribute of the specified object to the encryption information and the key information.
10. The method according to claim 9, characterized in that, The step of generating the code document for the target webpage based on the encrypted code and the business code includes: The encryption code is added to the business code according to the development format of the specified development language used in the business code; The code document is generated based on the added business code.
11. The method according to claim 8, characterized in that, The method further includes: The system receives a webpage request carrying encrypted data sent by the client. The webpage request is sent after the client has encrypted the data to be encrypted based on the encryption information. Obtain the decryption information associated with the target webpage, and decrypt the encrypted data based on the decryption information to obtain decrypted data; The corresponding response processing is performed based on the decrypted data to obtain operation response information, and the operation response information is sent to the client.
12. The method according to claim 11, characterized in that, The step of obtaining decryption information associated with the target webpage and decrypting the encrypted data based on the decryption information to obtain decrypted data includes: The decryption information is obtained by a decryption module deployed on the server. The decryption information includes the encryption method and decryption key information associated with the target webpage. The decryption module decrypts the encrypted data based on the encryption method and the decryption key information to obtain the decrypted data.
13. The method according to claim 8, characterized in that, The method further includes: Receive the second loading request sent by the client in response to the refresh operation of the target webpage; In response to the second loading request, obtain the updated encrypted information associated with the target webpage and the business code; An update encryption code is constructed based on the updated encryption information, and an update code document for the target webpage is generated based on the updated encryption code and the business code. The update response information carrying the update code document is sent to the client. The update response information is used to instruct the client to reload the target webpage based on the business code, and to encrypt the data to be encrypted obtained from the reloaded target webpage based on the update encryption code.
14. The method according to claim 13, characterized in that, After sending the response information carrying the code document to the client, the method further includes: Receive a connection establishment request sent by the client, which carries webpage information of the target webpage; In response to the connection establishment request, a connection response message is sent to the client, which instructs the client and the server to complete the establishment of a communication connection. If an update to the encrypted information associated with the target webpage is detected, a refresh instruction is sent to the client, which instructs the client to trigger a refresh operation on the target webpage.
15. A webpage data encryption processing device, characterized in that, Applied to the client side, including: The sending unit is used to send a first loading request for the target webpage to the server in response to the loading operation of the target webpage; A receiving unit is configured to receive response information returned by the server in response to the first loading request. The response information carries the code document of the target webpage. The code document is generated by the server based on the encrypted code and business code corresponding to the target webpage. The encrypted code is generated based on the encrypted information associated with the target webpage. The processing unit is used to load the target webpage based on the business code and to encrypt the data to be encrypted obtained from the target webpage based on the encryption code.
16. A webpage data encryption processing device, characterized in that, Applied to servers, including: The acquisition unit is used to acquire, in response to receiving a first loading request for a target webpage sent by a client, the encrypted information and business code associated with the target webpage; The processing unit is configured to construct encrypted code based on the encrypted information, and generate the code document of the target webpage based on the encrypted code and the business code; The sending unit is used to send response information carrying the code document to the client. The response information is used to instruct the client to load the target webpage based on the business code and to encrypt the data to be encrypted obtained from the target webpage based on the encryption code.
17. An electronic device, characterized in that, include: One or more processors; A memory for storing one or more computer programs that, when executed by one or more processors, cause the electronic device to implement the method for encrypting web page data according to any one of claims 1-7 or 8-14.
18. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method for encrypting web page data as described in any one of claims 1-7 or 8-14.
19. A computer program product, characterized in that, The computer program product includes a computer program stored in a computer-readable storage medium. The processor of the electronic device reads from the computer-readable storage medium and executes the computer program, causing the electronic device to perform the method for encrypting web page data according to any one of claims 1-7 or 8-14.
