CN111460464A - Data encryption and decryption method and device, electronic equipment and computer storage medium - Google Patents

Data encryption and decryption method and device, electronic equipment and computer storage medium Download PDF

Info

Publication number
CN111460464A
CN111460464A CN201910059476.5A CN201910059476A CN111460464A CN 111460464 A CN111460464 A CN 111460464A CN 201910059476 A CN201910059476 A CN 201910059476A CN 111460464 A CN111460464 A CN 111460464A
Authority
CN
China
Prior art keywords
programming language
encryption
decryption
algorithm
dynamic link
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910059476.5A
Other languages
Chinese (zh)
Other versions
CN111460464B (en
Inventor
王亚军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201910059476.5A priority Critical patent/CN111460464B/en
Publication of CN111460464A publication Critical patent/CN111460464A/en
Application granted granted Critical
Publication of CN111460464B publication Critical patent/CN111460464B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services

Abstract

The embodiment of the invention provides a data encryption and decryption method, a data encryption and decryption device, electronic equipment and a computer storage medium, wherein the data encryption and decryption method comprises the following steps: receiving to-be-processed original data transmitted by using a first programming language through an interface of a dynamic link library, wherein the dynamic link library is generated by using a second programming language; reflecting and calling an encryption algorithm or a decryption algorithm which is generated by adopting the first programming language and is outside the dynamic link library in the dynamic link library; and according to the type of the original data to be processed, encrypting or decrypting the original data to be processed by using a corresponding encryption algorithm or decryption algorithm. The embodiment of the invention reduces the size occupied by the dynamic link library and the maintenance cost, and effectively reduces the data processing burden and the resource consumption burden of the system.

Description

Data encryption and decryption method and device, electronic equipment and computer storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a data encryption and decryption method and device, electronic equipment and a computer storage medium.
Background
Data encryption is a process of converting plaintext into ciphertext through an encryption algorithm and an encryption key, and data decryption is a process of recovering ciphertext into plaintext through a decryption algorithm and a decryption key. And the data encryption and decryption ensure the safe interaction and transmission of the data.
In some systems or languages, however, there are security risks in encrypting and decrypting data. For example, in an android system implemented using Java language, since Java language is easily decompiled, App developed based on the android system is also easily decompiled, and security cannot be guaranteed. For this reason, the android system generally adopts C or C + + language to realize an encryption algorithm and a decryption algorithm, and then is integrated into the App in a manner of compiling into a link library. However, the algorithm library of the encryption and decryption algorithm implemented based on C or C + + is sometimes very large, not only the compilation is complex, but also the generated link library is large, which directly results in a large generated App, and increases the data processing burden and the resource consumption burden of the system.
Disclosure of Invention
In view of this, embodiments of the present invention provide a data encryption and decryption scheme to solve the problem of large data processing burden and resource consumption burden of a system caused by performing data encryption and decryption across languages in the prior art.
According to a first aspect of the embodiments of the present invention, there is provided a data encryption and decryption method, including: receiving to-be-processed original data transmitted by using a first programming language through an interface of a dynamic link library, wherein the dynamic link library is generated by using a second programming language; reflecting and calling an encryption algorithm or a decryption algorithm which is generated by adopting the first programming language and is outside the dynamic link library in the dynamic link library; and according to the type of the original data to be processed, encrypting or decrypting the original data to be processed by using a corresponding encryption algorithm or decryption algorithm.
According to a second aspect of the embodiments of the present invention, there is provided a data encryption and decryption apparatus, including: the system comprises a receiving module, a processing module and a processing module, wherein the receiving module is used for receiving to-be-processed original data transmitted by using a first programming language through an interface of a dynamic link library, and the dynamic link library is generated by using a second programming language; the calling module is used for calling an encryption algorithm or a decryption algorithm which is generated by adopting the first programming language and is outside the dynamic link library in a reflection mode in the dynamic link library; and the encryption and decryption module is used for encrypting or decrypting the original data to be processed by using a corresponding encryption algorithm or decryption algorithm according to the type of the original data to be processed.
According to a third aspect of embodiments of the present invention, there is provided an electronic apparatus, including: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus; the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to execute the operation corresponding to the data encryption and decryption method according to the first aspect.
According to a fourth aspect of embodiments of the present invention, there is provided a computer storage medium having stored thereon a computer program which, when executed by a processor, implements the data encryption and decryption method according to the first aspect.
According to the data encryption and decryption scheme provided by the embodiment of the invention, the encryption and decryption functions of the data are arranged in the dynamic link library, on one hand, the dynamic link library is difficult to be decompiled and cracked, so that the encryption and decryption algorithm arranged in the dynamic link library is difficult to be illegally known, and the data processed by the encryption and decryption algorithm in the dynamic link library has higher security; on the other hand, the dynamic link library can provide barrier-free calling among different programming languages, greatly improves the realization flexibility of the encryption and decryption algorithm, and reduces the realization cost of the encryption and decryption algorithm.
In addition, in the data encryption and decryption scheme provided by the embodiment of the invention, the dynamic link library does not use the second programming language of the dynamic link library to realize the encryption and decryption algorithm, but reflects and calls the external encryption and decryption algorithm written by the first programming language, so that the specific realization of the encryption and decryption algorithm is not required to be designed again, the size and the maintenance cost occupied by the realization content of the encryption and decryption algorithm are reduced, the size and the maintenance cost occupied by the dynamic link library are further reduced, and the data processing burden and the resource consumption burden of the system are effectively reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the embodiments of the present invention, and it is also possible for a person skilled in the art to obtain other drawings based on the drawings.
Fig. 1 is a flowchart illustrating steps of a data encryption and decryption method according to a first embodiment of the present invention;
FIG. 2 is a flowchart illustrating steps of a data encryption/decryption method according to a second embodiment of the present invention;
fig. 3 is a block diagram of a data encryption/decryption apparatus according to a third embodiment of the present invention;
fig. 4 is a block diagram of a data encryption/decryption apparatus according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be described clearly and completely with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments of the present invention shall fall within the scope of the protection of the embodiments of the present invention.
The following further describes specific implementation of the embodiments of the present invention with reference to the drawings.
Example one
Referring to fig. 1, a flowchart illustrating steps of a data encryption and decryption method according to a first embodiment of the present invention is shown.
The data encryption and decryption method of the embodiment comprises the following steps:
step S102: raw data to be processed transmitted using a first programming language is received through an interface of a dynamically linked library.
Wherein the dynamically linked library is generated using a second programming language.
In the embodiment of the invention, the encryption and decryption processing of the data is realized by the dynamic link library, so that the characteristic that the dynamic library cannot be reversely decoded is utilized, the encryption and decryption process is prevented from being decrypted by illegal decompilation, and the safety of the encryption process and the decryption process is protected.
In addition, the data encryption and decryption scheme of the embodiment of the invention is mainly suitable for cross-language data processing, so that a dynamic link library is used for realizing barrier-free calling among different programming languages. In the embodiment of the invention, the dynamic link library uses a language which is different from a main program and can be compiled. For the sake of distinction, the language used by the main program is referred to as a first programming language, and the language used by the dynamic link library is referred to as a second programming language.
When data needs to be encrypted or decrypted, the main program using the first programming language sends the data to be processed, namely the original data to be processed, to the dynamic link library through an interface provided by the dynamic link library, and correspondingly, the dynamic link library using the second programming language receives the original data to be processed sent by the main program through the interface of the dynamic link library so as to carry out encryption or decryption processing.
The dynamic link library may be implemented in any suitable form, including but not limited to an SO file or a D LL file.
Step S104: and reflecting and calling the encryption algorithm or the decryption algorithm which is generated by adopting the first programming language and is outside the dynamic link library in the dynamic link library.
Reflection calls are a way that can be assembled at runtime without the need for source code linking between components to create more flexible code. Through the reflection calling, the program can obtain the information of the class to be operated at the running time, and can obtain the complete construction of the class at the running time and call the corresponding method and attribute. Therefore, in the running state of the program, all the attributes and methods of any class can be known; any method and attribute of any object can be called, so that dynamic acquisition of information and dynamic calling of the object are realized.
In the embodiment of the invention, the encryption algorithm or the decryption algorithm outside the dynamic link library is called in the dynamic link library in a reflecting way, and the encryption algorithm and/or the decryption algorithm are compiled in the dynamic link library without using a second programming language, so that the specific realization of the encryption algorithm and the decryption algorithm does not need to be designed again, the size occupied by the realization content of the encryption algorithm and the maintenance cost are reduced, and the size occupied by the dynamic link library and the maintenance cost are further reduced.
It should be noted that, in the embodiment of the present invention, the encryption algorithm and the decryption algorithm may be any appropriate algorithms, and the specific implementation of the encryption algorithm and the decryption algorithm is not limited in the embodiment of the present invention. For example, there may be an MD5 algorithm, an AES algorithm, a BASE64 algorithm, and the like.
Step S106: and according to the type of the original data to be processed, encrypting or decrypting the original data to be processed by using a corresponding encryption algorithm or decryption algorithm.
The type of the original data to be processed is used for indicating whether the original data to be processed is a plaintext or a ciphertext, and if the original data to be processed is the plaintext, the plaintext is encrypted by using an encryption algorithm; and if the ciphertext is obtained, decrypting the ciphertext by using a decryption algorithm.
According to the embodiment, the encryption and decryption functions of the data are arranged in the dynamic link library, on one hand, the dynamic link library is difficult to decompile and crack, so that the encryption and decryption algorithm arranged in the dynamic link library is difficult to learn illegally, and the data processed by the encryption and decryption algorithm in the dynamic link library has higher security; on the other hand, the dynamic link library can provide barrier-free calling among different programming languages, greatly improves the realization flexibility of the encryption and decryption algorithm, and reduces the realization cost of the encryption and decryption algorithm.
In addition, in the embodiment, the dynamic link library does not use the second programming language of the dynamic link library to realize the encryption and decryption algorithm, but reflects and calls the external encryption and decryption algorithm written by adopting the first programming language, so that the specific realization of the encryption and decryption algorithm is not required to be designed again, the size occupied by the realization content of the encryption and decryption algorithm and the maintenance cost are reduced, the size occupied by the dynamic link library and the maintenance cost are further reduced, and the data processing burden and the resource consumption burden of the system are effectively reduced.
The data encryption and decryption method of the present embodiment may be executed by any suitable electronic device with data processing capability, including but not limited to: mobile terminals (such as mobile phones, PADs, etc.), servers, PCs, etc.
Example two
Referring to fig. 2, a flowchart illustrating steps of a data encryption and decryption method according to a second embodiment of the present invention is shown.
The data encryption and decryption method of the embodiment comprises the following steps:
step S202: and generating a dynamic link library for encrypting and decrypting the data.
The dynamic link library is provided with an algorithm for encrypting or decrypting data, and in a feasible mode, an encryption algorithm and/or a decryption algorithm generated by using a first programming language can be called in a set object by using a second programming language in a reflecting mode; and compiling the set object to generate a dynamic link library.
The setting object may be any suitable object that can be compiled into a dynamic link library, such as a dynamic link library item, a file, a function, a component, and the like, which is not limited in this embodiment of the present invention. Through a reflection calling mode, the specific implementation of the encryption and decryption algorithm does not need to be designed again, the size occupied by the implementation content of the encryption and decryption algorithm and the maintenance cost are reduced, and the size occupied by the dynamic link library and the maintenance cost are further reduced; the dynamic link library is generated by compiling, so that the security guarantee of the encryption and decryption algorithm and barrier-free calling among different programming languages are realized.
Optionally, the encryption algorithm and/or the decryption algorithm are/is an encryption algorithm and/or a decryption algorithm in a native class library of the first programming language, so that existing resources of the first programming language are utilized to the maximum extent, and implementation cost of data encryption and decryption is reduced.
For example, in an Android system, an encryption algorithm of a Java language is called by reflection of a dynamic link library realized by a C + + language.
First, assume that the encryption process implemented by the Java language is as follows:
MessageDigest digest getclass ═ messagedigest.getlnstance (md 5); creation of MessageDiget object by the static method getInstance of MessageDiget, with the argument stating that the encryption algorithm is MD5
byte [ ] result ═ digestclass. V/2. carry out encryption
Based on this, a dynamic link library project can be created, and the C + + language reflection is used in the dynamic link library project to call the encryption algorithm of the Java language, and the process can be implemented as follows:
creation of MessageDiget object by the static method getInstance of MessageDiget, with the argument stating that the encryption algorithm is MD5
//1.1 find the class corresponding to the java/security/Messagedigest path
jclass clazzMessageDigest=
env->FindClass("java/security/MessageDigest");
//1.2 find static method getInstance in class
jmethodID getInstance=
env->GetStaticMethodID(clazzMessageDigest,"getInstance","(Ljava/lang/String;)Ljava/security/MessageDigest;");
//1.3 execute the getInstance method with the parameter md5
jobject digestClass=
env->CallStaticObjectMethod(clazzMessageDigest,getInstance,md5);
V/2. carry out encryption
//2.1 first find the common method digest in class
methodIDdigest=env->GetMethodID(clazzMessageDigest,"digest","([B)[B");
//2.2 execute the digest method with the parameter bytes
jbyteArray result=
(jbyteArray)env->CallObjectMethod(messageDigest,digest,bytes);
After the corresponding encryption algorithm and decryption algorithm and other required information are set, compiling the created dynamic link library items to generate a final dynamic link library.
Of course, the above is only an exemplary illustration, and in practical application, a person skilled in the art may also implement the reflection call to the encryption and decryption algorithm in other suitable ways.
Once the dynamic link library is generated, the encryption and decryption services of the data can be continuously provided within a certain period of time, and the generation operation is not required to be carried out each time the data is encrypted and decrypted.
Step S204: raw data to be processed transmitted using a first programming language is received through an interface of a dynamically linked library.
Wherein the dynamically linked library is generated using a second programming language.
The generated dynamic link library is provided with a callable interface, and receives the original data to be processed through the interface so as to perform subsequent encryption or decryption operation.
In this embodiment, the first programming language is a semi-compiled and semi-interpreted language, and the second programming language is a compiled language, so as to effectively implement cross-language smooth conversion and call of data encryption and decryption. The semi-compiled and semi-interpreted languages are not compiled directly into machine code but into intermediate code at the time of compilation, such as Java language, C # language, etc., and the compiled languages need to be compiled into machine code by a compiler (compiler) before execution, such as C language, C + + language, Pascal language, Object-C language, etc.
Optionally, in a possible manner, the first programming language is Java language, and the second programming language is C language or C + + language. When the first programming language adopts Java language, a platform for compiling and debugging Java programs can be provided on any different operating systems as long as a Java running system is correctly installed, and the production efficiency and the applicability of the Java programs are greatly improved; and the second programming language adopts C language or C + + language, so that the confidentiality of the encryption and decryption algorithm is ensured, and the second programming language has wide applicability.
In addition, in the embodiment of the present invention, the original data to be processed may be plaintext data to be encrypted, or may be ciphertext data to be decrypted.
Step S206: and reflecting and calling the encryption algorithm or the decryption algorithm which is generated by adopting the first programming language and is outside the dynamic link library in the dynamic link library.
After the dynamic link library receives the original data to be processed through the interface, the algorithm in the dynamic link library can be executed on the original data to be processed, and the encryption algorithm or the decryption algorithm which is generated by adopting the first programming language and is outside the dynamic link library is called in a reflecting mode to perform corresponding encryption or decryption processing on the original data to be processed.
In one possible approach, this step can be implemented as: creating a reference to a class corresponding to an encryption algorithm or a decryption algorithm generated by adopting a first programming language outside the dynamic link library in the dynamic link library; calling an instantiation method in the class to instantiate the class and generate a corresponding class object; and calling an encryption algorithm or a decryption algorithm generated by adopting the first programming language through the class object.
For example, a reference to the MessageDigest class in the Java native class library may be created first by "env- > FindClass" as in the encryption algorithm in the dynamic link library generated in step S202; instantiating the MessageDiget class into a digestClass by calling and executing a 'getInstance' method; and then, calling an MD5 method in the Java native class library through the digestClass, and encrypting the character string to be encrypted converted into the byte array.
Therefore, the security of the dynamic link library mode is reused, the problem of overlarge dynamic link library is solved, the Java native algorithm is used, the security is guaranteed, and the encryption and decryption library is light and safe.
Step S208: and according to the type of the original data to be processed, encrypting or decrypting the original data to be processed by using a corresponding encryption algorithm or decryption algorithm.
For example, if the original data to be processed is a plaintext to be encrypted, the plaintext is transmitted into the dynamic link library, and then an encryption algorithm in the Java native class library is called through reflection to perform encryption operation, so as to obtain an encrypted ciphertext; or, if the original data to be processed is the encrypted ciphertext, the encrypted ciphertext is transmitted into the dynamic link library, and then a decryption algorithm in the Java native class library is called through reflection to perform decryption operation, so that the decrypted original text is obtained.
Step S210: and returning the result of encrypting or decrypting the original data to be processed.
The result after encryption or decryption can be directly returned to the Java main program, and further returned to the party requesting data encryption or data decryption, such as a certain service, through the Java main program.
According to the embodiment, the encryption and decryption functions of the data are arranged in the dynamic link library, on one hand, the dynamic link library is difficult to decompile and crack, so that the encryption and decryption algorithm arranged in the dynamic link library is difficult to learn illegally, and the data processed by the encryption and decryption algorithm in the dynamic link library has higher security; on the other hand, the dynamic link library can provide barrier-free calling among different programming languages, greatly improves the realization flexibility of the encryption and decryption algorithm, and reduces the realization cost of the encryption and decryption algorithm.
In addition, in the embodiment, the dynamic link library does not use the second programming language of the dynamic link library to realize the encryption and decryption algorithm, but reflects and calls the external encryption and decryption algorithm written by adopting the first programming language, so that the specific realization of the encryption and decryption algorithm is not required to be designed again, the size occupied by the realization content of the encryption and decryption algorithm and the maintenance cost are reduced, the size occupied by the dynamic link library and the maintenance cost are further reduced, and the data processing burden and the resource consumption burden of the system are effectively reduced.
The data encryption and decryption method of the present embodiment may be executed by any suitable electronic device with data processing capability, including but not limited to: mobile terminals (such as mobile phones, PADs, etc.), servers, PCs, etc.
EXAMPLE III
Referring to fig. 3, a block diagram of a data encryption and decryption apparatus according to a third embodiment of the present invention is shown.
The data encryption and decryption device of the embodiment comprises: a receiving module 302, configured to receive raw data to be processed, which is transmitted by using a first programming language, through an interface of a dynamic link library, where the dynamic link library is generated by using a second programming language; a calling module 304, configured to call, in a reflection manner, an encryption algorithm or a decryption algorithm, which is generated by using the first programming language, outside the dynamic link library in the dynamic link library; and the encryption and decryption module 306 is configured to encrypt or decrypt the raw data to be processed by using a corresponding encryption algorithm or decryption algorithm according to the type of the raw data to be processed.
The data encryption and decryption apparatus of this embodiment is used to implement the corresponding data encryption and decryption method in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which are not described herein again. In addition, the functional implementation of each module in the data encryption and decryption apparatus of this embodiment can refer to the description of the corresponding part in the foregoing method embodiment, and is not repeated here.
Example four
Referring to fig. 4, a block diagram of a data encryption and decryption apparatus according to a fourth embodiment of the present invention is shown.
The data encryption and decryption device of the embodiment comprises: a receiving module 402, configured to receive raw data to be processed, which is transmitted by using a first programming language, through an interface of a dynamic link library, where the dynamic link library is generated by using a second programming language; a calling module 404, configured to call, in a reflection manner, an encryption algorithm or a decryption algorithm, which is generated by using the first programming language, outside the dynamic link library in the dynamic link library; and the encryption and decryption module 406 is configured to encrypt or decrypt the raw data to be processed by using a corresponding encryption algorithm or decryption algorithm according to the type of the raw data to be processed.
Optionally, the data encryption and decryption apparatus of this embodiment further includes: a generating module 408, configured to call, in a set object, an encryption algorithm and/or a decryption algorithm generated using a first programming language using the second programming language reflection before the receiving module 402 receives, through an interface of a dynamic link library, to-be-processed raw data transmitted using the first programming language; and compiling the set object to generate the dynamic link library.
Optionally, the encryption algorithm and/or the decryption algorithm is an encryption algorithm and/or a decryption algorithm in a native class library of the first programming language.
Optionally, the invoking module 404 is configured to create, in the dynamically linked library, a reference to a class, which is external to the dynamically linked library and corresponds to an encryption algorithm or a decryption algorithm generated in the first programming language; calling an instantiation method in the class to instantiate the class and generate a corresponding class object; and calling an encryption algorithm or a decryption algorithm generated by adopting the first programming language through the class object.
Optionally, the first programming language is a semi-compiled semi-interpreted language, and the second programming language is a compiled language.
Optionally, the first programming language is Java language, and the second programming language is C language or C + + language.
The data encryption and decryption apparatus of this embodiment is used to implement the corresponding data encryption and decryption method in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which are not described herein again. In addition, the functional implementation of each module in the data encryption and decryption apparatus of this embodiment can refer to the description of the corresponding part in the foregoing method embodiment, and is not repeated here.
EXAMPLE five
Referring to fig. 5, a schematic structural diagram of an electronic device according to a sixth embodiment of the present invention is shown, and the specific embodiment of the present invention does not limit the specific implementation of the electronic device.
As shown in fig. 5, the electronic device may include: a processor (processor)502, a Communications Interface 504, a memory 506, and a communication bus 508.
Wherein:
the processor 502, communication interface 504, and memory 506 communicate with one another via a communication bus 508.
A communication interface 504 for communicating with other electronic devices or servers.
The processor 502 is configured to execute the program 510, and may specifically perform relevant steps in the above-described data encryption and decryption method embodiment.
In particular, program 510 may include program code that includes computer operating instructions.
The processor 502 may be a central processing unit CPU, or an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits configured to implement an embodiment of the invention. The intelligent device comprises one or more processors which can be the same type of processor, such as one or more CPUs; or may be different types of processors such as one or more CPUs and one or more ASICs.
And a memory 506 for storing a program 510. The memory 506 may comprise high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The program 510 may specifically be used to cause the processor 502 to perform the following operations: receiving to-be-processed original data transmitted by using a first programming language through an interface of a dynamic link library, wherein the dynamic link library is generated by using a second programming language; reflecting and calling an encryption algorithm or a decryption algorithm which is generated by adopting the first programming language and is outside the dynamic link library in the dynamic link library; and according to the type of the original data to be processed, encrypting or decrypting the original data to be processed by using a corresponding encryption algorithm or decryption algorithm.
In an alternative embodiment, the program 510 is further configured to enable the processor 502 to call an encryption algorithm and/or a decryption algorithm generated using the first programming language in the setting object using the second programming language reflection before the to-be-processed raw data transmitted using the first programming language is received by the interface of the dynamic link library; and compiling the set object to generate the dynamic link library.
In an alternative embodiment, the encryption algorithm and/or the decryption algorithm is an encryption algorithm and/or a decryption algorithm in a native class library of the first programming language.
In an alternative embodiment, program 510 is further configured to cause processor 502 to create a reference to a class corresponding to an encryption algorithm or decryption algorithm generated in the first programming language outside the dynamically linked library in the dynamically linked library when a reflection call is made in the dynamically linked library to an encryption algorithm or decryption algorithm generated in the first programming language outside the dynamically linked library; calling an instantiation method in the class to instantiate the class and generate a corresponding class object; and calling an encryption algorithm or a decryption algorithm generated by adopting the first programming language through the class object.
In an alternative embodiment, the first programming language is a semi-compiled semi-interpreted language and the second programming language is a compiled language.
In an alternative embodiment, the first programming language is Java language, and the second programming language is C language or C + + language.
For specific implementation of each step in the program 510, reference may be made to corresponding steps and corresponding descriptions in units in the foregoing data encryption and decryption method embodiments, which are not described herein again. It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described devices and modules may refer to the corresponding process descriptions in the foregoing method embodiments, and are not described herein again.
Through the electronic equipment of the embodiment, the encryption and decryption functions of the data are arranged in the dynamic link library, on one hand, the dynamic link library is difficult to be decompiled and cracked, so that the encryption and decryption algorithm arranged in the dynamic link library is difficult to be illegally known, and the data processed by the encryption and decryption algorithm in the dynamic link library has higher security; on the other hand, the dynamic link library can provide barrier-free calling among different programming languages, greatly improves the realization flexibility of the encryption and decryption algorithm, and reduces the realization cost of the encryption and decryption algorithm.
In addition, in the embodiment, the dynamic link library does not use the second programming language of the dynamic link library to realize the encryption and decryption algorithm, but reflects and calls the external encryption and decryption algorithm written by adopting the first programming language, so that the specific realization of the encryption and decryption algorithm is not required to be designed again, the size occupied by the realization content of the encryption and decryption algorithm and the maintenance cost are reduced, the size occupied by the dynamic link library and the maintenance cost are further reduced, and the data processing burden and the resource consumption burden of the system are effectively reduced.
It should be noted that, according to the implementation requirement, each component/step described in the embodiment of the present invention may be divided into more components/steps, and two or more components/steps or partial operations of the components/steps may also be combined into a new component/step to achieve the purpose of the embodiment of the present invention.
The above-described method according to an embodiment of the present invention may be implemented in hardware, firmware, or as software or computer code storable in a recording medium such as a CD ROM, a RAM, a floppy disk, a hard disk, or a magneto-optical disk, or as computer code originally stored in a remote recording medium or a non-transitory machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the method described herein may be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware such as an ASIC or FPGA. It is understood that a computer, processor, microprocessor controller, or programmable hardware includes memory components (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code that, when accessed and executed by a computer, processor, or hardware, implements the data encryption/decryption methods described herein. Further, when a general-purpose computer accesses code for implementing the data encryption/decryption method shown herein, execution of the code transforms the general-purpose computer into a special-purpose computer for performing the data encryption/decryption method shown herein.
Those of ordinary skill in the art will appreciate that the various illustrative elements and method steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present embodiments.
The above embodiments are only for illustrating the embodiments of the present invention and not for limiting the embodiments of the present invention, and those skilled in the art can make various changes and modifications without departing from the spirit and scope of the embodiments of the present invention, so that all equivalent technical solutions also belong to the scope of the embodiments of the present invention, and the scope of patent protection of the embodiments of the present invention should be defined by the claims.

Claims (14)

1. A data encryption and decryption method, comprising:
receiving to-be-processed original data transmitted by using a first programming language through an interface of a dynamic link library, wherein the dynamic link library is generated by using a second programming language;
reflecting and calling an encryption algorithm or a decryption algorithm which is generated by adopting the first programming language and is outside the dynamic link library in the dynamic link library;
and according to the type of the original data to be processed, encrypting or decrypting the original data to be processed by using a corresponding encryption algorithm or decryption algorithm.
2. The method of claim 1, wherein prior to receiving the raw data to be processed transmitted using the first programming language through the interface of the dynamically linked library, the method further comprises:
calling an encryption algorithm and/or a decryption algorithm generated by using the first programming language in a set object by using the second programming language reflection;
and compiling the set object to generate the dynamic link library.
3. The method of claim 1, wherein the encryption algorithm and/or the decryption algorithm is an encryption algorithm and/or a decryption algorithm in a native class library of the first programming language.
4. The method of any of claims 1-3, wherein reflectively invoking, in the dynamically linked library, an encryption algorithm or decryption algorithm generated in the first programming language external to the dynamically linked library comprises:
creating a reference to a class corresponding to an encryption algorithm or a decryption algorithm generated by the first programming language outside the dynamically linked library in the dynamically linked library;
calling an instantiation method in the class to instantiate the class and generate a corresponding class object;
and calling an encryption algorithm or a decryption algorithm generated by adopting the first programming language through the class object.
5. The method of any of claims 1-3, wherein the first programming language is a semi-compiled, semi-interpreted language and the second programming language is a compiled language.
6. The method of claim 5, wherein the first programming language is Java and the second programming language is C or C + +.
7. A data encryption/decryption apparatus comprising:
the system comprises a receiving module, a processing module and a processing module, wherein the receiving module is used for receiving to-be-processed original data transmitted by using a first programming language through an interface of a dynamic link library, and the dynamic link library is generated by using a second programming language;
the calling module is used for calling an encryption algorithm or a decryption algorithm which is generated by adopting the first programming language and is outside the dynamic link library in a reflection mode in the dynamic link library;
and the encryption and decryption module is used for encrypting or decrypting the original data to be processed by using a corresponding encryption algorithm or decryption algorithm according to the type of the original data to be processed.
8. The apparatus of claim 7, wherein the apparatus further comprises:
the generating module is used for calling an encryption algorithm and/or a decryption algorithm generated by using a first programming language in a set object by using the second programming language in a reflecting way before the receiving module receives the original data to be processed transmitted by using the first programming language through an interface of a dynamic link library; and compiling the set object to generate the dynamic link library.
9. The apparatus of claim 7, wherein the encryption algorithm and/or the decryption algorithm is an encryption algorithm and/or a decryption algorithm in a native class library of the first programming language.
10. The apparatus according to any one of claims 7-9, wherein the invoking module is configured to create, in the dynamically linked library, a reference to a class external to the dynamically linked library corresponding to an encryption algorithm or a decryption algorithm generated in the first programming language; calling an instantiation method in the class to instantiate the class and generate a corresponding class object; and calling an encryption algorithm or a decryption algorithm generated by adopting the first programming language through the class object.
11. The apparatus of any of claims 7-9, wherein the first programming language is a semi-compiled, semi-interpreted language and the second programming language is a compiled language.
12. The apparatus of claim 11, wherein the first programming language is Java language and the second programming language is C language or C + + language.
13. An electronic device, comprising: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to execute the operation corresponding to the data encryption and decryption method according to any one of claims 1-6.
14. A computer storage medium having stored thereon a computer program which, when executed by a processor, implements a data encryption/decryption method according to any one of claims 1 to 6.
CN201910059476.5A 2019-01-22 2019-01-22 Data encryption and decryption method and device, electronic equipment and computer storage medium Active CN111460464B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910059476.5A CN111460464B (en) 2019-01-22 2019-01-22 Data encryption and decryption method and device, electronic equipment and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910059476.5A CN111460464B (en) 2019-01-22 2019-01-22 Data encryption and decryption method and device, electronic equipment and computer storage medium

Publications (2)

Publication Number Publication Date
CN111460464A true CN111460464A (en) 2020-07-28
CN111460464B CN111460464B (en) 2023-04-25

Family

ID=71678960

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910059476.5A Active CN111460464B (en) 2019-01-22 2019-01-22 Data encryption and decryption method and device, electronic equipment and computer storage medium

Country Status (1)

Country Link
CN (1) CN111460464B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111988624A (en) * 2020-09-07 2020-11-24 北京达佳互联信息技术有限公司 Video processing method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080022267A1 (en) * 2004-04-26 2008-01-24 Google Inc. Method and System for Dynamically Composing Distributed Interactive Applications from High-Level Programming Languages
US20130125092A1 (en) * 2011-11-11 2013-05-16 General Electric Company Generating deployable code from simulation models
CN104077504A (en) * 2013-03-25 2014-10-01 联想(北京)有限公司 Method and device for encrypting application program
CN105978929A (en) * 2016-04-15 2016-09-28 北京思特奇信息技术股份有限公司 Method and system for data interaction between different mobile terminal platforms and back-end server
CN107992723A (en) * 2017-11-29 2018-05-04 南京莱斯信息技术股份有限公司 A kind of Java protection of source codes methods based on dynamic link library
CN108399318A (en) * 2018-01-31 2018-08-14 北京顶象技术有限公司 The generation method of executable file executes method and electronic equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080022267A1 (en) * 2004-04-26 2008-01-24 Google Inc. Method and System for Dynamically Composing Distributed Interactive Applications from High-Level Programming Languages
US20130125092A1 (en) * 2011-11-11 2013-05-16 General Electric Company Generating deployable code from simulation models
CN104077504A (en) * 2013-03-25 2014-10-01 联想(北京)有限公司 Method and device for encrypting application program
CN105978929A (en) * 2016-04-15 2016-09-28 北京思特奇信息技术股份有限公司 Method and system for data interaction between different mobile terminal platforms and back-end server
CN107992723A (en) * 2017-11-29 2018-05-04 南京莱斯信息技术股份有限公司 A kind of Java protection of source codes methods based on dynamic link library
CN108399318A (en) * 2018-01-31 2018-08-14 北京顶象技术有限公司 The generation method of executable file executes method and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111988624A (en) * 2020-09-07 2020-11-24 北京达佳互联信息技术有限公司 Video processing method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN111460464B (en) 2023-04-25

Similar Documents

Publication Publication Date Title
CN109766722B (en) Method for constructing intelligent contract in block chain
US9934375B2 (en) Secured execution of a web application
US9135434B2 (en) System and method for third party creation of applications for mobile appliances
KR101328012B1 (en) Apparatus for tamper protection of application code and method thereof
EP3038004A1 (en) Method for providing security for common intermediate language-based program
WO2021217980A1 (en) Java code packing method and system
CN104680039B (en) A kind of data guard method and device of application program installation kit
CN106415491B (en) Application protection method, server and terminal
CN106548046B (en) Device and method for protecting code
WO2023029447A1 (en) Model protection method, device, apparatus, system and storage medium
WO2016206297A1 (en) Method for protecting dex file from being decompiled in android system
CN110619224B (en) Data processing method and related device
CN107871066B (en) Code compiling method and device based on android system
CN111488169A (en) Method and device for hot updating of application program, storage medium and electronic equipment
CN111400743B (en) Transaction processing method, device, electronic equipment and medium based on blockchain network
CN111460464B (en) Data encryption and decryption method and device, electronic equipment and computer storage medium
CN112966227A (en) Code encryption and decryption method and device and storage medium
CN112115430A (en) Apk reinforcement method, electronic equipment and storage medium
CN114154123B (en) Encryption protection method applied to Python project
CN107403103B (en) File decryption method and device
CN113032741B (en) Class file encryption method, class file operation method, device, equipment and medium
CN113420313A (en) Program safe operation and encryption method and device, equipment and medium thereof
CN114329535A (en) File encryption method and device, electronic equipment and computer readable medium
CN113141329B (en) Big data mining method, device, equipment and storage medium
CN114039743A (en) Data encryption method, device, storage medium and terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant