CN107294702B - Front-end code encryption method based on Hybrid APP self characteristics - Google Patents
Front-end code encryption method based on Hybrid APP self characteristics Download PDFInfo
- Publication number
- CN107294702B CN107294702B CN201710581868.9A CN201710581868A CN107294702B CN 107294702 B CN107294702 B CN 107294702B CN 201710581868 A CN201710581868 A CN 201710581868A CN 107294702 B CN107294702 B CN 107294702B
- Authority
- CN
- China
- Prior art keywords
- key
- key segment
- hybrid app
- method based
- code
- 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.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/06—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
- H04L9/0643—Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0816—Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
- H04L9/085—Secret sharing or secret splitting, e.g. threshold schemes
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Power Engineering (AREA)
- Storage Device Security (AREA)
Abstract
The invention discloses a front-end code encryption method based on the self characteristics of Hybrid APP, which comprises the following steps: step 1, calculating and storing an MD5 value of a dex file of a Hybrid APP; step 2, encrypting the front js code file, wherein the encryption key is the MD5 value obtained in the step 1; step 3, dividing the MD5 value obtained in the step 2 into two segments, and recording the two segments as a key segment a and a key segment b; step 4, dispersedly inserting the key segment a into the encrypted ciphertext of the js code; step 5, storing the key segment b in a java function corresponding to the js page; and 6, during decryption, firstly extracting the key segment a from the ciphertext according to a rule, then extracting the key segment b from the java code, and splicing the key segment a and the key segment b to obtain a decryption key. The invention ensures the uniqueness of the key; the js page is unreadable, unavailable and not breakable under the condition of being separated from the APP environment, and the safety of the front-end code is guaranteed.
Description
Technical Field
The invention relates to a code encryption method, in particular to a front-end code encryption method based on Hybrid APP self characteristics, and belongs to the technical field of mobile terminal application safety.
Background
Hybrid APP is a Hybrid development application program, mainly comprising JS and Native, and realizes a mechanism of 'one-time development and multi-place operation' from a development level, so that the Hybrid APP becomes an application really suitable for cross-platform development. The Hybrid APP has the advantages of good user experience of Native APP and low cost of cross-platform development of Web APP by using HTML 5. It is statistical that more than 50% of mobile applications are currently hybrid development technologies in use.
With the development of mobile internet, mobile application security has become a hot issue of common concern for developers/publishers/users. At present, native APP on the market is generally reinforced by applying a shell adding mode, but the shell adding mode is only limited to dex files. js code exists as a resource file in the APP package, which is more readily available than native code, so protection against js code in Hybrid APP is the focus of developer research.
JavaScript is an interpreted scripting language in which the code is not pre-compiled prior to execution. Therefore, the code file cannot be encrypted and decrypted in the memory like a java file. At present, the js code encryption mode includes encoding and decoding character strings, using escape characters, adding null characters, adding useless contents and the like, but most of the js code encryption mode can only play a role of confusion, and the codes can be restored after a little time, so that the js code encryption mode is the most safe one to use, namely, an encryption and decryption algorithm.
At present, the js code in the Hybrid APP is generally protected by encrypting the code and then integrating decryption logic and ciphertext into a js file. In the encryption method, the js file can be easily decrypted after the key is stolen, and the source code is obtained, so that the key problem of selecting and storing the key is solved.
Disclosure of Invention
The invention provides a novel Hybrid APP front-end code encryption method, which mainly aims to solve the key selection and key hiding related to encryption and decryption. And the MD5 value of the APP dex file is used as an encryption and decryption key, the key is divided into two sections, one section is stored in front-end codes and one section is stored in java codes, and the two sections of keys are spliced and decrypted by the front-end codes during decryption. The method effectively realizes the hiding of the secret key and improves the safety of the front-end code on the premise of ensuring the operation efficiency.
In order to achieve the above object, the present invention adopts the following technical solutions.
A front-end code encryption method based on the self characteristics of Hybrid APP comprises the following steps:
step 1, calculating and storing an MD5 value of a dex file of a Hybrid APP;
step 2, encrypting the front js code file, wherein the encryption key is the MD5 value obtained in the step 1;
step 3, dividing the MD5 value obtained in the step 1 into two segments, and recording the two segments as a key segment a and a key segment b;
step 4, dispersedly inserting the key segments a into the encrypted text of the js code file;
step 5, storing the key segment b in a java function corresponding to the js code file page;
and 6, during decryption, firstly extracting the key segment a from the ciphertext according to a rule, then extracting the key segment b from the java function, and splicing the key segment a and the key segment b to obtain a decryption key.
The further scheme is as follows:
and 2, encrypting the front js code file by adopting any symmetric encryption algorithm.
The further scheme is as follows:
in step 3, the MD5 values are segmented using an arbitrary ratio.
The further scheme is as follows:
in step 3, the MD5 values are segmented by using an equal division method, and the lengths of the key segment a and the key segment b are both 64 bits.
The further scheme is as follows:
the specific steps of step 4 are as follows:
step 4.1, calculating the ciphertext length l;
and 4.2, generating 16 random numbers of [0, l ], arranging the random numbers in the sequence from small to large, and inserting the keys into corresponding positions in the ciphertext in bytes respectively.
The further scheme is as follows:
in step 5, the key segment b is integrally inserted into the java code.
The invention has the beneficial effects that:
1, the MD5 algorithm has the advantages of modification resistance and strong collision resistance, and the MD5 value of a dex file is used as an encryption key of a front-end code, so that the uniqueness of the key is ensured;
2, the key is divided into two sections and one section is stored in java codes of the js page, so that the js page is unreadable, unavailable and not breakable under the condition of being separated from the APP environment, and the safety of the front-end code is ensured to a great extent.
Drawings
FIG. 1 is an encryption flowchart based on the Hybrid APP self-body feature of the present invention.
Detailed Description
The present invention will be further described with reference to the accompanying drawings, and it should be noted that the present embodiment is based on the technical solution and provides detailed implementation and operation steps, but the protection scope of the present invention is not limited to the embodiment.
An encryption method based on the self characteristics of Hybrid APP is disclosed, as shown in FIG. 1:
step 1, calculating an MD5 value of a dex file of Hybrid APP by using a hashlib module built in python, and converting the MD5 value into a value 16 which is d82f7b5eeab972b53adbc3c1dda9794c in a binary system;
step 2, encrypting the js code file at the front end by using an AES algorithm, wherein the encryption key is the MD5 value obtained in the step 1;
step 3, dividing the MD5 value obtained in the step 2 into two sections equally, and recording the two sections as a key section a and a key section b;
and step 4, calculating the cipher text length l to 224, generating 16 random numbers of [0, l ] and sequencing the random numbers from small to large [31,41,47,59,77,83,90,100,143,163,167,173,186,197,219 and 220], and inserting the key segment a into corresponding positions in the cipher text in bytes respectively.
The ciphertext is:
eb3114b0621f234f228e159385c183478c7d5251bf744c3c728275e260daebd8794c4f26766b9c126f45a1c84d15355bd2c924595d0ff06f6bc65be131e973666e5335a1d0332518dc46563b3336194fb9cde6918eb025594896014cb6e7a736b15cddefda243e478dfcdcf8ce500706
the file after the key is inserted is:
eb3114b0621f234f228e159385c183d478c7d52581bf7424c3c728275ef260daebd8794c4f267766b9bc126f455a1c84d15e355bd2c924595d0ff06f6bc65be131e973666e5335ea1d0332518dc46563b3a336b194fb99cde6918eb02755948960142cb6e7a736b15cddefda24b53e478dfcdcf8ce500706
where the underlined characters are the keys.
Step 5, integrally storing the key section b in a java function corresponding to the js page;
and 6, during decryption, firstly extracting the key segment a from the ciphertext according to a rule, then extracting the key segment b from the java code, and splicing the key segment a and the key segment b to obtain a decryption key.
Various corresponding changes and modifications can be made by those skilled in the art based on the above technical solutions and concepts, and all such changes and modifications should be included in the protection scope of the present invention.
Although the present invention has been described herein with reference to the illustrated embodiments thereof, which are intended to be preferred embodiments of the present invention, it is to be understood that the invention is not limited thereto, and that numerous other modifications and embodiments can be devised by those skilled in the art that will fall within the spirit and scope of the principles of this disclosure.
Claims (6)
1. A front-end code encryption method based on Hybrid APP self characteristics is characterized by comprising the following steps:
step 1, calculating and storing an MD5 value of a dex file of a Hybrid APP;
step 2, encrypting the front js code file, wherein the encryption key is the MD5 value obtained in the step 1;
step 3, dividing the MD5 value obtained in the step 1 into two segments, and recording the two segments as a key segment a and a key segment b;
step 4, dispersedly inserting the key segments a into the encrypted text of the js code file;
step 5, storing the key segment b in a java function corresponding to the js page;
and 6, during decryption, firstly extracting the key segment a from the ciphertext according to a rule, then extracting the key segment b from the java function, and splicing the key segment a and the key segment b to obtain a decryption key.
2. The front-end code encryption method based on the Hybrid APP self-characteristics as claimed in claim 1, wherein:
and 2, encrypting the front js code file by adopting any symmetric encryption algorithm.
3. The front-end code encryption method based on the Hybrid APP self-characteristics as claimed in claim 1, wherein:
in step 3, the MD5 values are segmented using an arbitrary ratio.
4. The front-end code encryption method based on the Hybrid APP self-characteristics as claimed in claim 3, wherein:
in step 3, the MD5 values are segmented by using an equal division method, and the lengths of the key segment a and the key segment b are both 64 bits.
5. The front-end code encryption method based on the Hybrid APP self-characteristics as claimed in claim 1, wherein:
the specific steps of step 4 are as follows:
step 4.1, calculating the ciphertext length l;
and 4.2, generating 16 random numbers of [0, l ], arranging the random numbers in the sequence from small to large, and inserting the keys into corresponding positions in the ciphertext in bytes respectively.
6. The front-end code encryption method based on the Hybrid APP self-characteristics as claimed in claim 1, wherein:
in step 5, the key segment b is integrally inserted into the java code.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710581868.9A CN107294702B (en) | 2017-07-17 | 2017-07-17 | Front-end code encryption method based on Hybrid APP self characteristics |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710581868.9A CN107294702B (en) | 2017-07-17 | 2017-07-17 | Front-end code encryption method based on Hybrid APP self characteristics |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107294702A CN107294702A (en) | 2017-10-24 |
CN107294702B true CN107294702B (en) | 2020-04-28 |
Family
ID=60101014
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710581868.9A Active CN107294702B (en) | 2017-07-17 | 2017-07-17 | Front-end code encryption method based on Hybrid APP self characteristics |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107294702B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110008724B (en) * | 2019-03-29 | 2023-03-21 | 记忆科技(深圳)有限公司 | Solid state hard disk controller safe loading method and device and storage medium |
CN110535642B (en) * | 2019-09-02 | 2022-09-13 | 北京智游网安科技有限公司 | Method for distributing storage keys, intelligent terminal and storage medium |
CN111031023A (en) * | 2019-12-06 | 2020-04-17 | 苏州浪潮智能科技有限公司 | B/S communication method and device |
CN112597453A (en) * | 2020-12-04 | 2021-04-02 | 光大科技有限公司 | Program code encryption and decryption method and device |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB2421097A (en) * | 2004-12-10 | 2006-06-14 | Hewlett Packard Development Co | Identity based encryption for software distribution |
CN102598017A (en) * | 2009-11-13 | 2012-07-18 | 埃德图加拿大公司 | System and method to protect Java bytecode code against static and dynamic attacks within hostile execution environments |
CN106462699A (en) * | 2014-03-31 | 2017-02-22 | 爱迪德技术有限公司 | Software protection |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090210722A1 (en) * | 2007-11-28 | 2009-08-20 | Russo Anthony P | System for and method of locking and unlocking a secret using a fingerprint |
US8009831B2 (en) * | 2008-06-30 | 2011-08-30 | Condel International Technologies Inc. | Method and system for hiding the decryption key in a dispersive way |
-
2017
- 2017-07-17 CN CN201710581868.9A patent/CN107294702B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB2421097A (en) * | 2004-12-10 | 2006-06-14 | Hewlett Packard Development Co | Identity based encryption for software distribution |
CN102598017A (en) * | 2009-11-13 | 2012-07-18 | 埃德图加拿大公司 | System and method to protect Java bytecode code against static and dynamic attacks within hostile execution environments |
CN106462699A (en) * | 2014-03-31 | 2017-02-22 | 爱迪德技术有限公司 | Software protection |
Non-Patent Citations (1)
Title |
---|
增强本地代码安全性的Android软件保护方法;张鹏 等;《北京邮电大学学报》;20150228;第38卷(第1期);第21-25页 * |
Also Published As
Publication number | Publication date |
---|---|
CN107294702A (en) | 2017-10-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107294702B (en) | Front-end code encryption method based on Hybrid APP self characteristics | |
CN106599628B (en) | A kind of Python byte code files guard method based on module hook | |
CN106788995B (en) | File encryption method and device | |
JP2021513141A (en) | Generation and identification of 2D barcodes | |
CN106203128B (en) | Webpage data encryption and decryption method, device and system | |
CN110008745B (en) | Encryption method, computer equipment and computer storage medium | |
CN102355350B (en) | A kind of file encrypting method for mobile intelligent terminal and system | |
US8699703B2 (en) | System and method for pseudo-random polymorphic tree construction | |
CN108830096B (en) | Data processing method and device, electronic equipment and storage medium | |
WO2008141992A1 (en) | Method and apparatus for encrypting and decrypting software | |
CN110312054B (en) | Image encryption and decryption method, related device and storage medium | |
CN110210211A (en) | A kind of method of data protection and calculate equipment | |
CN111193741B (en) | Information sending method, information obtaining method, device and equipment | |
CN110096851B (en) | Byte code encryption method and system | |
CN109409101A (en) | The method and terminal device of data encryption | |
CN104200137A (en) | Method for guaranteeing self-security of JAVA program | |
CN111967032A (en) | File encryption method and decryption method based on obfuscation processing | |
KR20140139392A (en) | Method for generating application execution file for mobile device, application execution method of mobile device, device for generating application execution file and mobile device | |
CN104978539B (en) | Flash encryption and decryption methods and encryption, decryption device | |
US8832450B2 (en) | Methods and apparatus for data hashing based on non-linear operations | |
CN112966227A (en) | Code encryption and decryption method and device and storage medium | |
CN112199730A (en) | Method and device for processing application data on terminal and electronic equipment | |
CN105426702A (en) | Android operating system based application program encrypting method and device, and Android operating system based application program decrypting method and device | |
CN106059748B (en) | A kind of lightweight secure storage method of data regenerating code safely based on block | |
CN111523885B (en) | Encryption multi-account construction method for blockchain wallet, computer readable storage medium and blockchain encryption multi-account wallet |
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 |