Code hosting method and device and computer readable storage medium
By partially encrypting the user code in the code hosting platform and requiring the user to input private information for decryption, the problem in the existing technology that the code hosting platform cannot encrypt and protect the user code is solved, and the user experience and code security are improved.
Patent Information
- Application Number
- CN202310171779.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-27
- Publication Date
- 2024-09-03
AI Technical Summary
Due to the huge amount of code and frequent operations when hosting user code, existing code hosting platforms are unable to implement encryption protection before the code is placed on the disk, resulting in user code being easily stolen and poor user experience.
By marking the part of the code that the user wants to protect in the code file, it is encrypted using the key entered by the user to prevent theft, and the user is required to enter private information during the encryption and decryption process to ensure that only the user can decrypt it.
It effectively prevents the code that users want to protect from being stolen, improves users' code hosting experience, and ensures code security.
Smart Images

Figure CN118585232A
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and in particular to a code hosting method, device, and computer-readable storage medium. Background Art
[0002] Code hosting is an online code hosting service for software developers, which provides a cloud-based code repository with functions such as security management, member / permission management, branch protection / merging, online editing, and statistical services. Software developers can edit code anytime and anywhere without geographical restrictions.
[0003] At present, when the code hosting platforms provided by various manufacturers host user codes, due to the huge amount of code that users need to host and the frequent operations of users on the code (such as merging, editing, extracting, etc.), they are often unable to implement encryption protection before the code is stored on the disk, and the code can only be stored on the disk in plain text. Since the user code is stored on the disk in plain text, it is easy to be stolen. When using code hosting services, users will always worry about their code being stolen, and the user experience is poor. Summary of the invention
[0004] The present application provides a code hosting method, device and computer-readable storage medium, which can protect the user's code and optimize the user's code hosting experience.
[0005] In a first aspect, a code hosting method is provided, which is applied to a code hosting platform, and the method comprises the following steps: first, obtaining a first code set in a code file, the first code set including the code to be encrypted marked in the code file, then obtaining a first key input by a first user, or obtaining authentication information input by the first user, authenticating the first user according to the authentication information of the first user, obtaining the first key when the authentication is passed, and then using the first key to decrypt the encrypted second key to obtain the second key, and finally using the second key to encrypt the first code set to obtain the encrypted code.
[0006] In the above scheme, the code hosting platform encrypts the part of the code that the user wants to protect in the code file hosted by the user (i.e., the first code set mentioned above), thereby preventing the part of the code from being stolen. In this case, even if other codes of the user in the code file are stolen, the impact on the user is very small, thereby optimizing the user's code hosting experience. Furthermore, since the encryption is performed on the part of the code file that the user wants to protect, rather than the entire code file, the encryption and decryption performance is better, which can further optimize the user's code hosting experience.
[0007] In addition, in the above scheme, when the code is encrypted, since the key used to encrypt the code (i.e., the second key) requires the user to input private information (such as the first key, authentication information) to obtain it, therefore, when the encrypted code is decrypted, the key used to decrypt the code (i.e., the second key) also requires the user to input private information to obtain it. In this way, even if the thief steals the encrypted second key, the thief cannot crack the key used to decrypt the code because he does not know the user's private information, and thus cannot decrypt the part of the code that the user wants to protect. Therefore, the user's code security can be better protected and the user's code hosting experience can be further optimized.
[0008] In a possible implementation, the code file includes annotation information, and the annotation information is used to identify the first code set. In this case, the code hosting platform can specifically obtain the first code set in the following manner: obtain the first code set from the code file according to the annotation information in the code file.
[0009] In order to improve the flexibility of the solution, in another possible implementation method, the code hosting platform can specifically obtain the first code set in the following way: first, obtain the configuration file input by the first user, the configuration file includes annotation information, and the annotation information is used to identify the first code set, and then obtain the first code set from the code file according to the annotation information in the configuration file.
[0010] In order to further improve the flexibility of the solution, in another possible implementation method, the code hosting platform can specifically obtain the first code set in the following way: first, obtain the target code name selected by the first user from the preset key code names, and the preset key code names include at least one of the following: function name, class name, variable name, constant name, array name, and then extract the code corresponding to the target code name in the code file as the first code set.
[0011] In a possible implementation, before the code hosting platform obtains the first code set from the code file according to the annotation information, the method provided in the first aspect further includes the following steps: determining whether the annotation information is valid; at this time, the first code set can be obtained from the code file according to the annotation information in the following manner: when it is determined that the annotation information is valid, the first code set is obtained from the code file. In this way, it is possible to avoid obtaining the wrong code for encryption, thereby improving the accuracy of code encryption.
[0012] In a possible implementation, the code hosting platform can specifically obtain the first key in the following manner: first obtain the identifier of the first user, and then query the key mapping table according to the identifier of the first user to determine the first key, wherein the key mapping table is used to record the identifier and the first key of at least one user, and record the corresponding relationship between the identifier and the first key of at least one user, and the first user is any one of the at least one user.
[0013] In a possible implementation, the authentication information of the first user includes at least one of the following: fingerprint information, face information, iris information, voice, mobile phone verification code, email verification code, security question, ID number, passport number, and digital certificate.
[0014] In a second aspect, a code hosting method is provided, which is applied to a code hosting platform, and the method includes the following steps: first, obtaining an access request from a first user, the access request is used to view or edit a code file, the code file includes an encrypted code, the encrypted code is a code obtained by encrypting a first code set in the code file using a second key, the first code set includes the code to be encrypted marked in the code file, then, obtaining a first key input by the first user, or obtaining authentication information input by the first user, authenticating the first user according to the authentication information of the first user, obtaining the first key when the authentication is passed, and then using the first key to decrypt the encrypted second key to obtain the second key, and finally, presenting the first code set to the first user.
[0015] In a possible implementation, the first key can be obtained specifically in the following manner: obtaining the identifier of the first user; querying the key mapping table according to the identifier of the first user to determine the first key, the key mapping table being used to record the identifier and the first key of at least one user, and the correspondence between the identifier and the first key of at least one user, the first user being any one of the at least one user.
[0016] In a possible implementation, the authentication information of the first user includes at least one of the following: fingerprint information, face information, iris information, voice, mobile phone verification code, email verification code, security question, ID number, passport number, and digital certificate.
[0017] For the relevant beneficial effects and descriptions of the code hosting method provided in the second aspect and any implementation method of the second aspect, please refer to the relevant beneficial effects and descriptions of the code hosting method provided in the first aspect and any implementation method of the first aspect, which will not be repeated here.
[0018] In a third aspect, a code hosting device is provided, the device comprising:
[0019] An acquisition module, used for acquiring a first code set in a code file, wherein the first code set includes the code to be encrypted marked in the code file;
[0020] The acquisition module is further used to acquire a first key input by a first user, or acquire authentication information input by the first user, authenticate the first user according to the authentication information of the first user, and acquire the first key when the authentication is successful;
[0021] The encryption and decryption module is used to decrypt the encrypted second key using the first key to obtain the second key;
[0022] The encryption and decryption module is further used to encrypt the first code set using the second key to obtain an encrypted code.
[0023] In a possible implementation, the code file includes annotation information, and the annotation information is used to identify the first code set. The acquisition module can specifically acquire the first code set in the following manner: acquiring the first code set from the code file according to the annotation information in the code file.
[0024] In a possible implementation, the acquisition module can specifically acquire the first code set in the following manner: acquire a configuration file input by a first user, the configuration file includes annotation information, and the annotation information is used to identify the first code set; and acquire the first code set from the code file according to the annotation information in the configuration file.
[0025] In one possible implementation, the acquisition module can specifically implement the acquisition of the first code set in the following manner: obtain a target code name selected by a first user from preset key code names, where the preset key code names include at least one of the following: function name, class name, variable name, constant name, array name; extract the code corresponding to the target code name in the code file as the first code set.
[0026] In a possible implementation, the device provided by the third aspect also includes a judgment module, which is used to judge whether the annotation information is valid before the acquisition module acquires the first code set from the code file based on the annotation information. In this case, the acquisition module can specifically acquire the first code set in the following manner: when it is determined that the annotation information is valid, the first code set is acquired from the code file.
[0027] In one possible implementation, the acquisition module can specifically acquire the first key in the following manner: acquire the identifier of the first user; query the key mapping table according to the identifier of the first user to determine the first key, the key mapping table is used to record the identifier and the first key of at least one user, and record the correspondence between the identifier and the first key of at least one user, the first user is any one of the at least one user.
[0028] In a possible implementation, the authentication information of the first user includes at least one of the following: fingerprint information, face information, iris information, voice, mobile phone verification code, email verification code, security question, ID number, passport number, and digital certificate.
[0029] In a fourth aspect, a code hosting device is provided, the device comprising:
[0030] an acquisition module, configured to acquire an access request from a first user, the access request being used to view or edit a code file, the code file including an encrypted code, the encrypted code being a code obtained by encrypting a first code set in the code file using a second key, the first code set including the code to be encrypted that is marked in the code file;
[0031] The acquisition module is further used to acquire a first key input by a first user, or acquire authentication information input by the first user, authenticate the first user according to the authentication information of the first user, and acquire the first key when the authentication is successful.
[0032] The encryption and decryption module is used to decrypt the encrypted second key using the first key to obtain the second key;
[0033] The encryption and decryption module is further used to present the first code set to the first user.
[0034] In one possible implementation, the acquisition module can specifically acquire the first key in the following manner: acquire the identifier of the first user; query the key mapping table according to the identifier of the first user to determine the first key, the key mapping table is used to record the identifier and the first key of at least one user, and record the correspondence between the identifier and the first key of at least one user, the first user is any one of the at least one user.
[0035] In a possible implementation, the authentication information of the first user includes at least one of the following: fingerprint information, face information, iris information, voice, mobile phone verification code, email verification code, security question, ID number, passport number, and digital certificate.
[0036] In a fifth aspect, a computing device cluster is provided, the computing device cluster comprising a processor and a memory; the processor is used to execute instructions stored in the memory, so that the computing device cluster implements the method provided by the first aspect, the second aspect, or any possible implementation of the first aspect or the second aspect.
[0037] In a sixth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores instructions, and the instructions are used to implement the method provided by the first aspect, the second aspect, or any possible implementation of the first aspect or the second aspect.
[0038] In a seventh aspect, a computer program product is provided, comprising a computer program. When the computer program is read and executed by a computing device cluster, the computing device cluster executes the method provided by the first aspect, the second aspect, or any possible implementation of the first aspect or the second aspect.
[0039] In an eighth aspect, a code hosting platform is provided, including a code hosting device provided by the third aspect or any possible implementation of the third aspect, and a code hosting device provided by the fourth aspect or any possible implementation of the fourth aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a structural diagram of a code hosting system involved in this application;
[0041] Figure 2 It is a flowchart of a code hosting method provided by this application;
[0042] Figure 3A It is a schematic diagram of a first code set and annotation information of the first code set provided by the present application;
[0043] Figure 3B is a schematic diagram of another first code set and annotation information of the first code set provided by the present application;
[0044] Figure 4A It is a schematic diagram of a code hosting platform provided by the present application showing a first code file and a first code set;
[0045] Figure 4B It is a schematic diagram of another code hosting platform provided by the present application showing a first code file and a first code set;
[0046] Figure 5 It is a flowchart of another code hosting method provided by this application;
[0047] Figure 6 It is a structural diagram of a code hosting device provided by this application;
[0048] Figure 7 It is a structural schematic diagram of a computing device provided by the present application;
[0049] Figure 8 It is a structural diagram of a computing device cluster provided by this application;
[0050] Fig. 9 It is a structural diagram of another computing device cluster provided by this application. DETAILED DESCRIPTION
[0051] The technical solution provided by this application will be described below in conjunction with the accompanying drawings.
[0052] This application involves the scenario where users use the code hosting service to host code. Figure 1 , Figure 1 This is a schematic diagram of the structure of a code hosting system exemplified in this application, such as Figure 1 As shown, the system includes: a terminal device 110, a network device 120 and a code hosting platform 130.
[0053] The terminal device 110 may be an electronic device such as a personal computer, a tablet computer, or a mobile notebook. A user may write code through the terminal device 110 and access the code hosting platform 130 through the terminal device 110 for code hosting. Figure 1 The terminal device 110 is taken as an example of a personal computer, but this application does not make a specific limitation on this.
[0054] The network device 120 is used to transmit data between the terminal device 110 and the code hosting platform 130 through a communication network of any communication mechanism / communication standard. The communication network can be a wide area network, a local area network, a point-to-point connection, or any combination thereof.
[0055] The code hosting platform 130 may be a platform that provides code hosting services, and may specifically be a personal computer, a general-purpose physical server, such as an X86 server or an ARM server, etc., or a cloud-based server, which is not specifically limited in this application.
[0056] Figure 1 Taking the code hosting platform 130 as a cloud-based server as an example, the code hosting platform 130 may include multiple code hosting nodes, and the code hosting nodes may provide code hosting services to users. Each code hosting node includes service hardware, virtualization services, and code hosting server applications.
[0057] The service hardware includes computing resources, storage resources, and network resources. The computing resources may adopt a heterogeneous computing architecture, for example, a central processing unit (CPU) + graphics processing unit (GPU) architecture, a CPU + AI chip, a CPU + GPU + AI chip architecture, etc., which are not specifically limited here. Storage resources may include memory, disks, etc. Here, computing resources may be divided into a plurality of computing unit resources, storage resources may be divided into a plurality of storage unit resources, and network resources may be divided into a plurality of network unit resources. Therefore, the code hosting platform 130 may be freely combined based on unit resources according to the user's resource requirements, thereby providing resources for the user's needs. For example, computing resources may be divided into 5u computing unit resources, and storage resources may be divided into 10G storage unit resources. Then the combination of computing resources and storage resources may be 5u + 10G, 5u + 20G, 5u + 30u, ..., 10u + 10G, 10u + 20G, 10u + 30u, ....
[0058] Virtualization service is a service that uses virtualization technology to build the resources of multiple physical hosts into a unified resource pool, and flexibly isolates independent resources according to user needs to run user applications. Virtualization services can include virtual machine (VM) services, bare metal server (BMS) services, and container services. Among them, VM service can be a service that uses virtualization technology to virtualize virtual machine (VM) resource pools on multiple physical hosts to provide VMs for users to use on demand. BMS service is a service that virtualizes BMS resource pools on multiple physical hosts to provide BMS for users to use on demand. Container service is a service that virtualizes container resource pools on multiple physical hosts to provide containers for users to use on demand. VM is a simulated virtual computer, that is, a logical computer. BMS is a high-performance computing service that can be elastically scalable, with computing performance that is no different from that of traditional physical machines, and has the characteristics of secure physical isolation. Container is a kernel virtualization technology that can provide lightweight virtualization to achieve the purpose of isolating user space, processes and resources. It should be understood that the VM service, BMS service and container service in the above-mentioned virtualization services are only specific examples. In actual applications, virtualization services can also be other lightweight or heavyweight virtualization services, which are not specifically limited here.
[0059] The code hosting server application can be used to receive the code hosting client application ( Figure 1The code hosting server application may receive a hosting request carrying a code file sent by a user through a code hosting client application on the terminal device 110, and then search for the corresponding code file from the code repository and present it to the user. The code repository may be a public or private space created by a user in the storage resources of the code hosting platform 130 for storing a large amount of code.
[0060] It should be understood that Figure 1 The code hosting system shown is only an example. In actual applications, the code hosting system may include any number of terminal devices 110, network devices 120, and code hosting platforms 130. The code hosting system may also include other or more components. Figure 1 It should not be considered as specifically limiting.
[0061] At present, when the code hosting platform 130 provided by various manufacturers hosts the user's code, due to the huge amount of code that the user needs to host and the frequent operations of the user on the code (such as merging, editing, extracting, etc.), it is often impossible to implement encryption protection before the code is stored on the disk (referring to storage in the code warehouse), and the code can only be stored on the disk in plain text. Since it is stored on the disk in plain text, the user's code is easily stolen, such as being stolen by the operation and maintenance personnel of the code hosting platform 130, or because the operating system of the code hosting platform 130 is hacked and the code is stolen, etc. When using the code hosting service, users will always worry about their code being stolen, and the user experience is poor.
[0062] In order to solve the above problems, the present application provides a code hosting method and device, which can be applied to Figure 1 The code hosting system shown can be applied to Figure 1 The code hosting platform 130 is shown.
[0063] In the code hosting method and device provided in the present application, when the code hosting platform 130 receives a code file that the user wants to host, it can locate the part of the code (such as the core code) that the user wants to protect in the code file based on the annotation information added by the user to the part of the code that the user wants to protect in the code file, and then encrypt the part of the code. Therefore, it can prevent the part of the code that the user wants to protect from being stolen. In this case, even if other code in the code file is stolen, the impact on the user is very small, thereby optimizing the user's code hosting experience.
[0064] In addition, in the code hosting method and device provided in the present application, the key used by the code hosting platform 130 to encrypt and decrypt the code requires the user to enter private information to obtain it. Since the user's private information is private to the user, it is difficult for a thief to obtain the user's private information. If the user's private information cannot be stolen, the thief cannot crack the key used to encrypt and decrypt the code, and thus cannot decrypt the part of the code that the user wants to protect. Therefore, the user's code security can be better protected and the user's code hosting experience can be further optimized.
[0065] In order to facilitate a clearer understanding of the code hosting method and device provided by the present application, they are introduced below in conjunction with the corresponding drawings.
[0066] First, see Figure 2 , Figure 2 A flowchart of a code hosting method provided for this application. Figure 2 In the description, the code hosting platform 130 is used as the execution entity.
[0067] like Figure 2 As shown, the code hosting method provided by this application includes the following steps:
[0068] S201: The code hosting platform 130 obtains a first key and a second key input by a first user, uses the first key to perform an encryption operation on the second key to obtain an encrypted second key, and saves the encrypted second key.
[0069] The first user can Figure 2 The users of the terminal device 110 shown are, usually, a first user who is a developer.
[0070] In a possible embodiment, the code hosting platform 130 only saves the encrypted second key, and does not save the first key and the second key. In this way, the second key can be prevented from being stolen by the operation and maintenance personnel of the code hosting platform 130, and the second key can be prevented from being stolen by hackers when the code hosting platform 130 is hacked, thereby improving the security of the second key and protecting the security of the code subsequently encrypted using the second key.
[0071] S202: The code hosting platform 130 obtains a first code file of a first user, where the first code file includes a first code set, and the first code set includes the to-be-encrypted code marked in the first code file.
[0072] The first code file may be a code file written by the first user on his terminal device 110, and then sent to the code hosting platform 130 for hosting. The first code file may be a code written in any programming language (such as C++, Java, Visual Basic), and the first code file may include one or more directories, each directory may include one or more lines of code, and one or more lines of code may include functions, classes, variables, constants, arrays, etc. The first code file may also not include a directory, but directly include one or more lines of code. This application does not specifically limit the first code file.
[0073] The first code file may be code written independently by the first user, or may be code written collaboratively by multiple users including the first user. In the case where the first code file is code written collaboratively by multiple users, each user may also authorize the code written by the user. For example, assuming that the first code file includes directory 1 and directory 2, wherein the code under directory 1 is code written by user A, and the code under directory 2 is code written by user B, user A may authorize user B to have read-only permission for the code under directory 1, and authorize user C to have editing permission for the code under directory 1, and user B may authorize user A to have management permission for the code under directory 2, and authorize user C to have read-only permission for the code under directory 2.
[0074] The first code set can be understood as the code that the first user wants to protect, which can be one or more directories in the first code file, or one or more lines of code, or one or more functions, classes, variables, constants, arrays, etc., that is, including part of the code in the first code file. In a specific implementation, the first code set can also include all the codes in the first code file, and this application does not specifically limit the content of the first code set. For the notation form of the first code set, please refer to the relevant description in S203.
[0075] S203: The code hosting platform 130 extracts a first code set from the first code file.
[0076] Specifically, the code hosting platform 130 may refer to any one of the following methods 1 to 3 to implement the extraction of the first code set:
[0077] Mode 1: The first code file includes annotation information added by the first user for the first code set. The code hosting platform 130 can locate the first code set from the first code file according to the annotation information in the first code file, thereby acquiring the first code set.
[0078] The annotation information may be a combination of a "start mark + an end mark", an identifier of the first code set, etc. The identifier of the first code set may be a name of the first code set, location information of the first code set in the first code file, etc.
[0079] Take the combination of "start mark + end mark" as an example, see Figure 3A The first code set and the annotation information of the first code set shown in Figure 3A In the example, the start mark is start and the end mark is end.
[0080] Take the position information of the first code set in the first code file as an example, see Figure 3B The first code set and the annotation information of the first code set shown in Figure 3B In the figure, the marking information is "1+4+7", where 1 represents the first line of code of the first code file, 4 represents the fourth line of code of the first code file, and 7 represents the seventh line of code of the first code file.
[0081] Taking the annotation information as the name of the first code set as an example, assuming that the first code set is the code under directory A in the first code file, and the name of the first code set is the name of directory A, then the annotation information can be the name of directory A. Assuming that the first code set is all functions B in the first code file, such as the sum (add) function, and the name of the first code set is the name of function B, then the annotation information can be the name of function B. Assuming that the first code set is all functions B in directory A, and the name of the first code set is "name of directory A + name of function B", then the annotation information can be "name of directory A + name of function B".
[0082] It should be understood that the above-mentioned form of the annotation information is only an example. For example, in a specific implementation, the start mark in the annotation information can be represented by 000000 and the end mark can be represented by 111111. This application does not specifically limit the form of the annotation information.
[0083] Method 2: The first user can add annotation information for the first code set in the configuration file, and then submit the configuration file including the annotation information to the code hosting platform 130. The code hosting platform 130 can locate the first code set from the first code file according to the annotation information in the configuration file, thereby obtaining the first code set.
[0084] In method 2, the annotation information may be an identifier of the first code set, a copy of the first code set, etc., and this application does not make any specific limitation on this.
[0085] Method 3: The code hosting platform 130 may set some preset key code names, such as function names, class names, variable names, constant names, array names, etc. When the first user submits the first code file to the code hosting platform 130 for saving, the code hosting platform 130 may display the preset key code names to the first user, and then obtain the target code name selected by the first user from the preset key code names. Thereafter, the target code name is identified from the first code file to obtain a first code set. Here, the first code set includes the code corresponding to the target code name. Taking the target code name as a function name as an example, the code corresponding to the target code name is the function corresponding to the function name. Taking the target code name as a class name as an example, the code corresponding to the target code name is the class corresponding to the class name. Taking the target code name as a variable name as an example, the code corresponding to the target code name is the variable corresponding to the variable name.
[0086] It should be understood that the above methods 1 to 3 are merely examples of methods for the code hosting platform 130 to obtain the first code set from the first code file. Other methods that can achieve obtaining the first code set from the first code file also fall within the scope of protection of this application and will not be elaborated here.
[0087] In a possible embodiment, before obtaining the first code set, the code hosting platform 130 may also determine whether the annotation information is valid. If the annotation information is determined to be valid, the first code set is obtained from the first code file. If the annotation information is determined to be invalid, the first user may be prompted to modify the annotation information, and then determine whether the modified annotation information is valid, and so on. In this way, it is possible to avoid obtaining wrong codes for encryption, thereby improving the accuracy of code encryption.
[0088] Taking the valid annotation information as the above-mentioned "start mark + end mark" as an example, if the code hosting platform 130 finds that each start mark in the first code file has a matching end mark, it is determined that the annotation information in the first code file is valid; otherwise, it is determined that the annotation information in the first code file is invalid.
[0089] Taking the first code file including 100 lines of code as an example, if the code hosting platform 130 finds that the position information included in the annotation information is between lines [1, 100], it is determined that the annotation information is valid; otherwise, it is determined that the annotation information is invalid.
[0090] Taking the first code file not including function A as an example, if the code hosting platform 130 finds that the annotation information is the name of function A, and function A cannot be located in the first code file according to the name of function A, then it is determined that the annotation information is invalid; otherwise, it is determined that the annotation information is valid.
[0091] It should be understood that the above-mentioned methods for determining whether the annotation information is valid are merely examples, and other methods that can achieve the determination of whether the annotation information is valid also fall within the scope of protection of this application, and this application does not make any specific limitations on this.
[0092] S204: The code hosting platform 130 prompts the first user to input a third key.
[0093] S205: The code hosting platform 130 uses the third key to decrypt the encrypted second key. When the third key is the same as the first key, the decryption is successful, the second key is obtained, and S206 is executed. When the third key is different from the first key, the decryption fails, and the first user is prompted to modify the third key.
[0094] After prompting the first user to modify the third key, the code hosting platform 130 can obtain the modified third key, and use the modified third key to decrypt the encrypted second key. When the modified third key is the same as the first key, the decryption is successful, and the second key is obtained. Then S206 is executed. When the modified third key is different from the first key, the decryption fails, and the first user is prompted to modify the modified third key, and so on. Further, the code hosting platform 130 can lock the account of the first user when the number of decryption failures reaches a preset number threshold.
[0095] S206: The code hosting platform 130 uses the second key to encrypt the first code set, thereby obtaining an encrypted code.
[0096] S207: The code hosting platform 130 saves the encrypted code and the first code file to the code repository.
[0097] Specifically, the code hosting platform 130 can write the encrypted code into the second code file, and the location where the first code set was originally located in the first code file is idle or replaced by other codes, text, symbols, etc., such as replaced by an "*", and then save the first code file and the second code file to the code warehouse, or the code hosting platform 130 can merge the encrypted code into the first code file, and then save the first code file to the code warehouse.
[0098] It can be understood that in a specific implementation, a large number of users may use the code hosting platform 130 for code hosting, that is, a large number of users' code files may be stored in the code repository. In order to distinguish the code files of a large number of users, the code hosting platform 130 will record the correspondence between the user's identifier and the identifier of the user's code file while saving the user's code file to the code repository, so that when the user needs to access his or her own code file later, the code hosting platform 130 can find the corresponding code file from the large number of code files stored in the code repository according to the user's identifier and the identifier of the code file that the user wants to access, and present it to the user.
[0099] S208: The code hosting platform 130 obtains an access request from the first user, where the access request is used to view or edit the first code file.
[0100] The access request may include an identifier of the first code file and an identifier of the first user. After obtaining the access request, the code hosting platform 130 may search for the first code file from the code repository according to the identifier of the first user and the identifier of the first code file.
[0101] S209: the code hosting platform 130 searches for the first code file from the code repository according to the access request.
[0102] S210: The code hosting platform 130 determines that the first code file contains encrypted code, and prompts the first user to input a fourth key.
[0103] S211: The code hosting platform 130 uses the fourth key to decrypt the encrypted second key. When the fourth key is the same as the first key, the decryption is successful, the second key is obtained, and S212 is executed. When the fourth key is different from the first key, the decryption fails, and the first user is prompted to modify the fourth key.
[0104] After prompting the first user to modify the fourth key, the code hosting platform 130 can obtain the modified fourth key, and use the modified fourth key to decrypt the encrypted second key. When the modified fourth key is the same as the first key, the decryption is successful, and the second key is obtained. Then S212 is executed. When the modified fourth key is different from the first key, the decryption fails, and the first user is prompted to modify the modified fourth key, and so on. Further, the code hosting platform 130 can lock the account of the first user when the number of decryption failures reaches a preset number threshold.
[0105] In the event of a decryption failure, the code hosting platform 130 may refuse to open the first code file, or allow the first code file to be opened, but when opening the first code file, only other contents in the first code file that are allowed to be viewed or edited by the first user except the first code set are presented to the first user, and the first code set is in an invisible state.
[0106] S212: The code hosting platform 130 decrypts the encrypted code using the second key to obtain a first code set, and presents the first code set to the first user.
[0107] As can be seen from the above description of S207, the encrypted code can be stored in the first code file or the second code file. When the encrypted code is stored in the first code file, the code hosting platform 130 can directly use the second key to decrypt the encrypted code in the first code file, thereby obtaining a first code file including the first code set, and then directly display the first code set in the opened first code file, such as Figure 4A As shown; when the encrypted code is stored in the second code file, the code hosting platform 130 can directly use the second key to decrypt the encrypted code in the second code file, thereby obtaining the second code file including the first code set, and then extract the first code set from the second code file, store the first code set back into the first code file, and finally, directly display the first code set in the opened first code file, or, after obtaining the second code file including the first code set, directly open the first code file and the second code file, and display the first code set through the second code file, as shown in FIG. Figure 4B shown.
[0108] It is understandable that when presenting the first code set to the first user, the code hosting platform 130 may also present to the first user other contents in the first code file that are allowed to be viewed or edited by the first user, such as Figure 4A and Figure 4B shown.
[0109] See next Figure 5 , Figure 5 A flowchart of another code hosting method provided for this application is shown in Figure 5 In the present invention, the code hosting platform 130 is still used as the execution entity for introduction.
[0110] like Figure 5 As shown, the code hosting method provided by this application includes the following steps:
[0111] S501: The code hosting platform 130 obtains a first identifier, a first key, and a second key input by a first user, uses the first key to perform an encryption operation on the second key to obtain an encrypted second key and saves the encrypted second key, where the first identifier is the identifier of the first user.
[0112] The first identifier may be the first user's work ID, email address, mobile phone number, ID number, passport number, fingerprint information, face information, iris information, etc.
[0113] S502: The code hosting platform 130 uses the first key mapping table to record the first identifier, the first key, and the correspondence between the first identifier and the first key, and sends the first key mapping table to the key management platform.
[0114] The key management platform usually has a relatively high level of security protection and can protect the key-related information stored locally.
[0115] It can be understood that the code hosting platform 130 only saves the encrypted second key, sends the first key mapping table to a key management platform with a higher security protection level, and does not save the first key mapping table itself. In this way, the second key can be prevented from being stolen by the operation and maintenance personnel of the code hosting platform 130, and the second key can be prevented from being stolen by hackers when the code hosting platform 130 is hacked, thereby protecting the security of the second key and thus protecting the security of the code subsequently encrypted using the second key.
[0116] In a specific implementation, when the code hosting platform 130 provides code hosting services for a large number of users including the first user, it can use a first key mapping table to record the identifiers of multiple users including the first identifier, the keys of multiple users used to encrypt the second key, and the corresponding relationship between the identifier of each user and the key of each user, and use a second key mapping table to record the identifiers of multiple users including the first identifier, and the keys after the multiple users encrypt the second key. See Table 1 and Table 2, Table 1 is an exemplary first key mapping table shown in the present application, and Table 2 is an exemplary second key mapping table shown in the present application.
[0117] Table 1 First key mapping table
[0118] User's ID The key used to encrypt the second key 000 123456 001 654321 002 123654 … …
[0119] Table 2 Second key mapping table
[0120] User's ID The key after encrypting the second key 000 694354 001 648436 002 745340 … …
[0121] It can be understood that the above Tables 1 and 2 are merely examples to reflect the user's identification, the key used by the user to encrypt the second key, the key after the user encrypts the second key, and the correspondence between them. In a specific implementation, the contents recorded in the first key mapping table and the second key mapping table and the correspondence may also be in other forms, which are not specifically limited here.
[0122] In a possible embodiment, the code hosting platform 130 only saves the second key mapping table, sends the first key mapping table to a key management platform with a higher security protection level, and does not save the first key mapping table itself. In this way, the security of the second key can be protected, thereby protecting the security of the code subsequently encrypted by each user using the second key.
[0123] S503: The code hosting platform 130 obtains a first code file input by a first user, where the first code file includes a first code set, and the first code set includes the to-be-encrypted code marked in the first code file.
[0124] S504: The code hosting platform 130 extracts a first code set from the first code file.
[0125] S505: The code hosting platform 130 prompts the first user to input first authentication information.
[0126] The first authentication information, i.e., the authentication information of the first user, may include at least one of the following: user name, password, fingerprint information, face information, iris information, voice, mobile phone verification code, email verification code, security question, ID number, passport number, digital certificate, wherein the security question may be "What is your birthday?", "What is your age?", "What is your favorite color?", "What is the name of your favorite star?", etc. It should be understood that the authentication information may also be other, and this application does not specifically limit the authentication information.
[0127] In a specific embodiment of the present application, before S501, the first user can send a registration request to the code hosting platform 130 to apply for registration. The registration request can carry the first user's registration information, such as user name, password, email address, mobile phone number, ID number, passport number, fingerprint information, face information, iris information, digital certificate, selected security questions, etc. The code hosting platform 130 can review the first user's registration information. If the review is passed, the first user's registration information is saved, so that the code hosting platform 130 can authenticate the user based on the saved first user's registration information. If the review is not passed, the first user is prompted to modify the registration information and re-register. After the first user successfully registers, the first user can use the code hosting platform 130 for code hosting.
[0128] S506: the code hosting platform 130 authenticates the first user according to the first authentication information. If the authentication is successful, S507 is executed. If the authentication is not successful, the first user is prompted to modify the first authentication information.
[0129] After prompting the first user to modify the first authentication information, the code hosting platform 130 can obtain the modified first authentication information, use the modified first authentication information to authenticate the first user, and when the authentication is successful, execute S507, and when the authentication is unsuccessful, prompt the first user to modify the modified first authentication information, and so on. Further, the code hosting platform 130 can lock the account of the first user when the number of authentication failures reaches a preset number threshold.
[0130] S507: The code hosting platform 130 obtains the first identifier, queries the first key mapping table according to the first identifier, and obtains the first key.
[0131] The first authentication information may carry the first identifier, and therefore, the code hosting platform 130 may obtain the first identifier from the first authentication information. Alternatively, the code hosting platform 130 may store login information when the first user logs into the code hosting platform 130, and the login information includes the first identifier. Therefore, the code hosting platform 130 may obtain the first identifier from the login information. Alternatively, the code hosting platform 130 may also prompt the first user to input the first identifier and obtain the first identifier input by the first user. This application does not specifically limit the manner in which the code hosting platform 130 obtains the first identifier.
[0132] S508: The code hosting platform 130 uses the first key to decrypt the encrypted second key to obtain the second key.
[0133] The code hosting platform 130 may query the second key mapping table according to the first identifier to obtain the encrypted second key corresponding to the first user.
[0134] S509: the code hosting platform 130 uses the second key to encrypt the first code set, thereby obtaining an encrypted code.
[0135] S510: The code hosting platform 130 saves the encrypted code and the first code file to the code repository.
[0136] S511: The code hosting platform 130 obtains an access request from a first user, where the access request is used to view or edit a first code file.
[0137] S512: The code hosting platform 130 searches for a first code file from the code repository according to the access request.
[0138] S513: The code hosting platform 130 determines that the first code file contains encrypted code, and prompts the first user to input second authentication information.
[0139] The second authentication information, which is also the authentication information of the first user, may include at least one of the following: user name, password, fingerprint information, face information, iris information, voice, mobile phone verification code, email verification code, security question, ID number, passport number, digital certificate. It should be understood that the authentication information may also be other, and this application does not make specific limitations on the authentication information.
[0140] S514: the code hosting platform 130 authenticates the first user according to the second authentication information. If the authentication is successful, S515 is executed. If the authentication is not successful, the first user is prompted to modify the second authentication information.
[0141] After prompting the first user to modify the second authentication information, the code hosting platform 130 can obtain the modified second authentication information, use the modified second authentication information to authenticate the first user, and when the authentication is successful, execute S507, and when the authentication is unsuccessful, prompt the first user to modify the modified second authentication information, and so on. Further, the code hosting platform 130 can lock the account of the first user when the number of authentication failures reaches a preset number threshold.
[0142] S515: The code hosting platform 130 obtains the first identifier, queries the first key mapping table according to the first identifier, and obtains the first key.
[0143] The access request or the second authentication information may carry the first identifier, and therefore, the code hosting platform 130 may obtain the first identifier from the access request or the second authentication information. Alternatively, the code hosting platform 130 may store login information when the first user logs into the code hosting platform 130, and the login information includes the first identifier. Therefore, the code hosting platform 130 may obtain the first identifier from the login information. Alternatively, the code hosting platform 130 may also prompt the first user to input the first identifier and obtain the first identifier input by the first user. This application does not specifically limit the manner in which the code hosting platform 130 obtains the first identifier.
[0144] S516: The code hosting platform 130 uses the first key to decrypt the encrypted second key to obtain the second key.
[0145] The code hosting platform 130 may query the second key mapping table according to the first identifier to obtain the encrypted second key corresponding to the first user.
[0146] S517: The code hosting platform 130 decrypts the encrypted code using the second key to obtain a first code set, and presents the first code set to the first user.
[0147] It can be seen that the above S503 corresponds to the same as S202, S504 corresponds to the same as S203, S509 corresponds to the same as S206, S510 corresponds to the same as S207, S511 corresponds to the same as S208, S512 corresponds to the same as S209, and S517 corresponds to the same as S212. For details, please refer to Figure 2 For the sake of brevity, the description of the corresponding steps will not be elaborated here.
[0148] In a possible embodiment, in S501, the first key may not be input by the first user to the code hosting platform 130, but the code hosting platform 130 randomly generates a key factor after obtaining the first identifier input by the first user, and then generates it according to the first identifier and the key factor. In S502, the code hosting platform 130 uses the first key mapping table to record the first identifier, the key factor and the corresponding relationship between the first identifier and the key factor, or uses the first key mapping table to record the first identifier, the first key and the corresponding relationship between the first identifier and the first key, and then sends the first key mapping table to the key management platform, and then executes S503 to S517. Optionally, the first key may also be generated according to the first identifier and the key factor after the key management platform generates the key factor, and then sent to the code hosting platform 130.
[0149] In a possible embodiment, in S201 and S501, the second key may not be input by the first user to the code hosting platform 130, but generated by the code hosting platform 130. Alternatively, the second key may also be generated by the key management platform and then sent to the code hosting platform 130.
[0150] It should be noted that Figure 2 , Figure 5 In the illustrated embodiment, the first key and the second key may be symmetric keys or asymmetric keys, which are not specifically limited in this application. A symmetric key is also called a private key, which means that the encryption party and the decryption party must use the same key to encrypt and decrypt data. An asymmetric key includes a pair of keys: a public key and a private key. These two keys are different keys. If the encryption party uses a public key to encrypt data, the decryption party can only decrypt it with the corresponding private key.
[0151] It should be noted that Figure 2 , Figure 5The illustrated embodiment is described by taking the example of encrypting the first code set after the code hosting platform 130 extracts the first code set from the first code file. In a specific implementation, the code hosting platform 130 may not extract the first code set from the first code file, but directly use the second key to encrypt the first code set in the first code file, so that the first code set is invisible in the first code file, and then the first code file is saved in the code repository.
[0152] pass Figure 2 , Figure 5 It can be seen from the illustrated embodiments that when hosting a user's code file, the code hosting method provided by the present application can locate the portion of code (i.e., the above-mentioned first code set) in the code file based on the annotation information added by the user to the portion of code in the code file that the user wants to protect, and then encrypt the portion of code. Therefore, the portion of code can be prevented from being stolen. In this case, even if other codes of the user in the code file are stolen, the impact on the user is very small, thereby optimizing the user's code hosting experience.
[0153] pass Figure 2 , Figure 5 It can also be seen from the illustrated embodiment that in the code hosting method provided by the present application, the key used for encrypting and decrypting the code (i.e., the above-mentioned second key) requires the user to input private information (such as the first key, the user's authentication information) to obtain it. Since the user's private information is private to the user, it is difficult for a thief to obtain the user's private information. If the user's private information cannot be stolen, the thief cannot crack the key used for encrypting and decrypting the code, and thus cannot decrypt the part of the code that the user wants to protect. Therefore, the user's code security can be better protected, and the user's code hosting experience can be further optimized.
[0154] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0155] The above text has elaborated in detail the code hosting method provided by the present application. Based on the same inventive concept, the following text will continue to introduce the code hosting device and computing equipment provided by the present application.
[0156] See also Figure 6 , Figure 6 is a schematic diagram of a code hosting device 600 provided in the present application. The device 600 can be applied to Figure 1The code hosting platform 130 shown in the figure, the device 600 includes: an acquisition module 610 and an encryption and decryption module 620. The functions of each module of the code hosting device 600 are introduced exemplarily below. It should be understood that the functions of each module described by way of example below are only functions that the code hosting device 600 may have in some embodiments of the present application, and the present application does not limit the functions of each module.
[0157] An acquisition module 610 is used to acquire a first code set in a code file, where the first code set includes the code to be encrypted marked in the code file;
[0158] The acquisition module 610 is further configured to acquire a first key input by a first user, or acquire authentication information input by the first user, authenticate the first user according to the authentication information of the first user, and acquire the first key when the authentication is successful;
[0159] The encryption and decryption module 620 is used to decrypt the encrypted second key using the first key to obtain the second key;
[0160] The encryption and decryption module 620 is further configured to encrypt the first code set using the second key to obtain an encrypted code.
[0161] In a possible embodiment, the code file includes annotation information, and the annotation information is used to identify the first code set. The acquisition module 610 can be used to acquire the first code set from the code file according to the annotation information in the code file.
[0162] In another possible embodiment, the acquisition module 610 can be specifically used to obtain a configuration file input by a first user, where the configuration file includes annotation information, where the annotation information is used to identify the first code set, and then the first code set is obtained from the code file according to the annotation information in the configuration file.
[0163] In another possible embodiment, the acquisition module 610 may be specifically used to acquire a target code name selected by the first user from preset key code names, and then extract the code corresponding to the target code name in the code file as the first code set. The preset key code name includes at least one of the following: function name, class name, variable name, constant name, array name.
[0164] In a possible embodiment, before the acquisition module 610 acquires the first code set from the code file according to the annotation information, the apparatus 600 may further include a determination module 630 (e.g. Figure 6), a judgment module 630 is used to judge whether the annotation information is valid, and the acquisition module 610 is specifically used to: when the judgment module 630 determines that the annotation information is valid, obtain the first code set from the code file. In this embodiment, the device 600 may also include a prompt module 640 (as shown in FIG. Figure 6 As shown), the prompt module 640 is specifically used to: when the judgment module 630 determines that the annotation information is invalid, prompt the first user to modify the annotation information.
[0165] In a possible embodiment, the acquisition module 610 can specifically implement the acquisition of the first key in the following manner: obtain the identifier of the first user, query the key mapping table according to the identifier of the first user, and determine the first key, the key mapping table is used to record the identifier and the first key of at least one user, and record the correspondence between the identifier and the first key of at least one user, and the first user is any one of the at least one user.
[0166] In a possible embodiment, the authentication information of the first user includes at least one of the following: fingerprint information, face information, iris information, voice, mobile phone verification code, email verification code, security question, ID number, passport number, digital certificate.
[0167] It can be seen that the above-mentioned device 600 can be used to encrypt the code files hosted by the user.
[0168] In a possible embodiment, the above device 600 can also be used to decrypt the encrypted code in the code file hosted by the user. During the decryption process, the functions of each module in the device 600 are as follows:
[0169] An acquisition module 610 is used to acquire an access request from a first user, where the access request is used to view or edit a code file;
[0170] The acquisition module 610 is further configured to acquire a first key input by a first user, or acquire authentication information input by the first user, authenticate the first user according to the authentication information of the first user, and acquire the first key when the authentication is successful;
[0171] The encryption and decryption module 620 is used to decrypt the encrypted second key using the first key to obtain the second key;
[0172] The encryption and decryption module 620 is further configured to present the first code set to the first user.
[0173] Among them, the acquisition module 610, the encryption and decryption module 620, the judgment module 630, and the prompt module 640 can all be implemented by software, or can be implemented by hardware. Exemplarily, the implementation of the encryption and decryption module 620 is introduced below by taking the encryption and decryption module 620 as an example. Similarly, the implementation of the acquisition module 610, the judgment module 630, and the prompt module 640 can refer to the implementation of the encryption and decryption module 620.
[0174] As an example of a software functional unit, the encryption and decryption module 620 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical server (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more. For example, the encryption and decryption module 620 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including a data center or multiple data centers with similar geographical locations. Among them, usually a region may include multiple AZs.
[0175] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0176] As an example of a hardware functional unit, the encryption and decryption module 620 may include at least one computing device. Alternatively, the encryption and decryption module 620 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0177] The multiple computing devices included in the encryption / decryption module 620 can be distributed in the same region or in different regions. The multiple computing devices included in the encryption / decryption module 620 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the encryption / decryption module 620 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0178] It should be noted that, in other embodiments, the encryption and decryption module 620 can be used to execute Figure 2 , Figure 5 The acquisition module 610 can be used to execute any step in the code hosting method provided by the present application. Figure 2 , Figure 5 In any step of the code hosting method provided by the present application, the judgment module 630 can be used to execute Figure 2 , Figure 5 In any step of the code hosting method provided by the present application, the prompt module 640 can be used to execute Figure 2 , Figure 5 In any step of the code hosting method provided by the present application, the steps implemented by the acquisition module 610, the encryption and decryption module 620, the judgment module 630, and the prompt module 640 can be specified as needed, and the acquisition module 610, the encryption and decryption module 620, the judgment module 630, and the prompt module 640 can be respectively implemented Figure 2 , Figure 5 The different steps in the code hosting method provided by the present application are shown to implement all functions of the code hosting device 600 .
[0179] The present application also provides a computing device 700, such as Figure 7 As shown, the computing device 700 includes: a bus 702, a processor 704, a memory 706 and a communication interface 708. The processor 704, the memory 706 and the communication interface 708 communicate through the bus 702. The computing device 700 can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop, a laptop or a smart phone. It should be understood that the present application does not limit the number of processors and memories in the computing device 700.
[0180] The bus 702 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 The bus 702 may include a path for transmitting information between various components of the computing device 700 (eg, the memory 706, the processor 704, and the communication interface 708).
[0181] The processor 704 may include any one or more processors such as a CPU, a GPU, a microprocessor (MP), or a digital signal processor (DSP).
[0182] The memory 706 may include a volatile memory, such as a random access memory (RAM). The processor 704 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0183] The memory 706 stores executable program codes, and the processor 704 executes the executable program codes to respectively implement the functions of the aforementioned acquisition module 610, encryption and decryption module 620, judgment module 630 and prompt module 640, thereby implementing Figure 2 , Figure 5 The code hosting method provided by the present application is shown. That is, the memory 706 stores instructions for executing the code hosting method provided by the present application.
[0184] The communication interface 708 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 700 and other devices or communication networks.
[0185] The present application also provides a computing device cluster 800, which includes at least one computing device 700. Figure 8 shown.
[0186] The memory 706 in one or more computing devices 700 in the computing device cluster 800 may store the same instructions for executing the code hosting method provided by the present application.
[0187] In some possible implementations, the memory 706 of one or more computing devices 700 in the computing device cluster 800 may also respectively store some instructions for executing the code hosting method provided by the present application. In other words, the combination of one or more computing devices 700 may jointly execute instructions for executing the code hosting method provided by the present application.
[0188] It should be noted that the memory 706 in different computing devices 700 in the computing device cluster 800 may store different instructions, which are respectively used to execute part of the functions of the code hosting apparatus 600. That is, the instructions stored in the memory 706 in different computing devices 700 may implement the functions of one or more modules among the acquisition module 610, the encryption and decryption module 620, the judgment module 630, and the prompt module 640.
[0189] In some possible implementations, one or more computing devices 700 in the computing device cluster 800 may be connected via a network, which may be a wide area network or a local area network. Fig. 9 A possible implementation is shown, such as Fig. 9 As shown, two computing devices 700A and 700B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 706 in the computing device 700A stores instructions for executing the functions of the acquisition module 610, the judgment module 630, and the prompt module 640. At the same time, the memory 706 in the computing device 700B stores instructions for executing the functions of the encryption and decryption module 620.
[0190] Fig. 9 The connection method between the computing device cluster 800 shown may be based on the consideration that the code hosting method provided in the present application requires encryption and decryption of a large amount of code, and therefore the functions implemented by the encryption and decryption module 620 may be handed over to the computing device 700B for execution.
[0191] It should be understood that Fig. 9 The functions of the computing device 700A shown in FIG. 7 may also be completed by multiple computing devices 700. Similarly, the functions of the computing device 700B may also be completed by multiple computing devices 700.
[0192] The present application also provides a computer program product including instructions, which may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the code hosting method provided by the present application.
[0193] The present application also provides a computer-readable storage medium, which can be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc. The computer-readable storage medium includes instructions that instruct the computing device to execute the code hosting method provided by the present application.
[0194] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.
Claims
1. A code hosting method, It is characterized in that The method comprises: The code hosting platform obtains a first code set in a code file, where the first code set includes the code to be encrypted marked in the code file; The code hosting platform obtains the first key input by the first user, or obtains authentication information input by the first user, authenticates the first user according to the authentication information of the first user, and obtains the first key when the authentication passes; The code hosting platform uses the first key to decrypt the encrypted second key to obtain the second key; The code hosting platform uses the second key to encrypt the first code set, thereby obtaining encrypted code.
2. The method according to claim 1, It is characterized in that The code file includes annotation information, and the annotation information is used to identify the first code set. The code hosting platform obtains the first code set in the code file, including: The code hosting platform obtains the first code set from the code file according to the annotation information in the code file.
3. The method according to claim 1, It is characterized in that The code hosting platform obtains a first code set in the code file, including: The code hosting platform obtains a configuration file input by the first user, where the configuration file includes annotation information, and the annotation information is used to identify the first code set; The code hosting platform obtains the first code set from the code file according to the annotation information in the configuration file.
4. The method according to claim 1, It is characterized in that The code hosting platform obtains a first code set in the code file, including: The code hosting platform obtains the target code name selected by the first user from preset key code names, where the preset key code name includes at least one of the following: function name, class name, variable name, constant name, array name; The code hosting platform extracts the code corresponding to the target code name in the code file as the first code set.
5. The method according to claim 2 or 3, It is characterized in that Before the code hosting platform obtains the first code set from the code file according to the annotation information, the method further includes: The code hosting platform determines whether the annotation information is valid; The code hosting platform acquiring the first code set from the code file according to the annotation information includes: When determining that the annotation information is valid, the code hosting platform obtains the first code set from the code file.
6. The method according to any one of claims 1 to 5, It is characterized in that The code hosting platform obtains the first key, including: The code hosting platform obtains the identifier of the first user; The code hosting platform queries a key mapping table according to the identifier of the first user to determine the first key, wherein the key mapping table is used to record the identifier of at least one user and the first key, and the corresponding relationship between the identifier of the at least one user and the first key, and the first user is any one of the at least one user.
7. The method according to any one of claims 1 to 6, It is characterized in that The authentication information of the first user includes at least one of the following: fingerprint information, face information, iris information, voice, mobile phone verification code, email verification code, security question, ID number, passport number, and digital certificate.
8. A code hosting method, It is characterized in that The method comprises: The code hosting platform obtains an access request from a first user, the access request being used to view or edit a code file, the code file including an encrypted code, the encrypted code being a code obtained by encrypting a first code set in the code file using a second key, the first code set including the code to be encrypted marked in the code file; The code hosting platform obtains the first key input by the first user, or obtains the authentication information input by the first user, authenticates the first user according to the authentication information of the first user, and obtains the first key when the authentication passes; The code hosting platform uses the first key to decrypt the encrypted second key to obtain the second key; The code hosting platform presents the first code set to the first user.
9. The method according to claim 8, It is characterized in that The code hosting platform obtains the first key, including: The code hosting platform obtains the identifier of the first user; The code hosting platform queries a key mapping table according to the identifier of the first user to determine the first key, wherein the key mapping table is used to record the identifier of at least one user and the first key, and the corresponding relationship between the identifier of the at least one user and the first key, and the first user is any one of the at least one user.
10. The method according to claim 8 or 9, It is characterized in that The authentication information of the first user includes at least one of the following: fingerprint information, face information, iris information, voice, mobile phone verification code, email verification code, security question, ID number, passport number, and digital certificate.
11. A code hosting device, It is characterized in that The device comprises: An acquisition module, configured to acquire a first code set in a code file, wherein the first code set includes the code to be encrypted marked in the code file; The acquisition module is further configured to acquire a first key input by a first user, or acquire authentication information input by the first user, authenticate the first user according to the authentication information of the first user, and acquire the first key when the authentication is successful; an encryption and decryption module, configured to use the first key to decrypt the encrypted second key to obtain the second key; The encryption and decryption module is further used to encrypt the first code set using the second key to obtain an encrypted code.
12. The device according to claim 11, It is characterized in that The code file includes annotation information, and the annotation information is used to identify the first code set. The acquisition module is specifically used to: The first code set is obtained from the code file according to the annotation information in the code file.
13. The device according to claim 11, It is characterized in that The acquisition module is specifically used for: Acquire a configuration file input by the first user, where the configuration file includes annotation information, and the annotation information is used to identify the first code set; The first code set is obtained from the code file according to the annotation information in the configuration file.
14. The device according to claim 11, It is characterized in that The acquisition module is specifically used for: Obtaining a target code name selected by the first user from preset key code names, wherein the preset key code name includes at least one of the following: a function name, a class name, a variable name, a constant name, and an array name; The code corresponding to the target code name in the code file is extracted as the first code set.
15. The device according to claim 12 or 13, It is characterized in that Before acquiring the first code set from the code file according to the annotation information, the device further includes: A judging module, used to judge whether the marking information is valid; The acquisition module is specifically used for: When it is determined that the annotation information is valid, the first code set is obtained from the code file.
16. The device according to any one of claims 11 to 15, It is characterized in that The acquisition module is specifically used for: Obtaining an identifier of the first user; A key mapping table is queried according to the identifier of the first user to determine the first key, the key mapping table is used to record the identifier of at least one user and the first key, and the correspondence between the identifier of the at least one user and the first key, the first user is any one of the at least one user.
17. The device according to any one of claims 11 to 16, It is characterized in that The authentication information of the first user includes at least one of the following: fingerprint information, face information, iris information, voice, mobile phone verification code, email verification code, security question, ID number, passport number, and digital certificate.
18. A code hosting device, It is characterized in that The device comprises: an acquisition module, configured to acquire an access request of a first user, wherein the access request is used to view or edit a code file, wherein the code file includes an encrypted code, wherein the encrypted code is a code obtained by encrypting a first code set in the code file using a second key, wherein the first code set includes the marked code to be encrypted in the code file; The acquisition module is further configured to acquire a first key input by the first user, or acquire authentication information input by the first user, authenticate the first user according to the authentication information of the first user, and acquire the first key when the authentication is successful; an encryption and decryption module, configured to use the first key to decrypt the encrypted second key to obtain the second key; The encryption and decryption module is further used to present the first code set to the first user.
19. The device according to claim 18, It is characterized in that The encryption and decryption module is used to: Obtaining an identifier of the first user; A key mapping table is queried according to the identifier of the first user to determine the first key, the key mapping table is used to record the identifier of at least one user and the first key, and the correspondence between the identifier of the at least one user and the first key, the first user is any one of the at least one user.
20. The device according to claim 18 or 19, It is characterized in that The authentication information of the first user includes at least one of the following: fingerprint information, face information, iris information, voice, mobile phone verification code, email verification code, security question, ID number, passport number, and digital certificate.
21. A computing device cluster, It is characterized in that comprising at least one computing device, each computing device of the at least one computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 10.
22. A computer-readable storage medium, It is characterized in that The method comprises computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method according to any one of claims 1 to 10.
23. A computer program product, It is characterized in that The computer program product comprises instructions, and when the instructions are executed by a computing device cluster, the computing device cluster performs the method according to any one of claims 1 to 10.
24. A code hosting platform, It is characterized in that The platform includes the code hosting device according to any one of claims 11 to 17 and the code hosting device according to any one of claims 18 to 20.
