Specific embodiment
It is to make purpose, technical scheme and the advantage of the application clearer, specifically real below in conjunction with the application
Apply example and corresponding accompanying drawing is clearly and completely described to technical scheme.Obviously, it is described
Embodiment is only some embodiments of the present application, rather than the embodiment of whole.Based on the enforcement in the application
Example, the every other enforcement obtained under the premise of creative work is not made by those of ordinary skill in the art
Example, belongs to the scope of the application protection.
The process of the encryption that Fig. 1 is provided for the embodiment of the present application, specifically includes following steps:
S101:Obtain plaintext string.
In the embodiment of the present application, encryption device obtains plaintext string to be encrypted first.Specifically, plus
Close device can determine that the character string of user input, used as the plaintext string to be encrypted for getting.Wherein,
User can be input into plaintext string when password is arranged, then the plaintext string can be described as standard plaintext character
String, user also can be input into plaintext string in verification, then the plaintext string can be described as plaintext word to be certified
Symbol string.Described encryption device can be terminal, it is also possible to server.
S102:The plaintext string is encrypted using at least two AESs, is obtained accordingly extremely
Few two kinds of ciphertext character strings.
After encryption device gets plaintext string, can select from the multiple encryption algorithms for pre-saving
At least two AESs, and the plaintext string is carried out adding using at least two AESs selected
It is close, obtain corresponding at least two ciphertexts character string.
Wherein, at least two AESs for being adopted can be in the multiple encryption algorithms for pre-saving with
What machine was selected.The multiple encryption algorithms for pre-saving may include such as the 5th edition (Mes of message digest algorithm
Sage-Digest Algorithm 5, MD5), Secure Hash Algorithm 1 (Secure Hash Algorithm 1,
) and the AES such as safe gibberish standard (Secure Hash Standard, SHS) SHA1.Example
Such as, it is assumed that the plaintext string that encryption device is obtained is " drami890 ", in the various encryptions for pre-saving
Two kinds of different AESs of MD5 and SHA1 are randomly selected in algorithm, then can be by the MD5 of selection
AES is encrypted to plaintext string " drami890 ", obtains ciphertext character string " woeijoc123s
Oijesoiej333gienpmxde ", by the SHA1 AESs of selection to plaintext string " drami890 "
It is encrypted, obtains ciphertext character string " xxifmeng3255die5234fecj7hntu9dqafh ", obtaining not
After same ciphertext character string, encryption device will be processed to different ciphertext character strings.
S103:Character is intercepted in the every kind of ciphertext character string for obtaining respectively.
After different ciphertext character strings are obtained, encryption device will intercept character in each ciphertext character string, right
For the every kind of ciphertext character string obtained by different AESs, the character of intercepting is not complete
Ciphertext character string, that is, when being intercepted for a kind of ciphertext character string, only intercepting the ciphertext character string
In partial character.
Specifically, when encryption device intercepts character in each ciphertext character string, several can first be generated more than 0
Random number, further according to generate each random number, intercept character in the every kind of ciphertext character string for obtaining respectively.
Further, when character being intercepted according to random number, can be directed to each random number, at least two for obtaining
Select a kind of in ciphertext character string, then random intercepting character, the character of intercepting from the ciphertext character string for selecting
Quantity be exactly the random number.
In order to ensure only to intercept a part of character when intercepting in a ciphertext character string, encryption device is generated
Each random number be smaller than the minima in the digit of at least two ciphertexts character string.
Continue to use the example above, the plaintext string " drami890 " for obtaining is entered by AES MD5
The digit that ciphertext character string is obtained after row encryption is 32, and ciphertext character string is obtained after being encrypted by SHA1
Digit be 34, in the two ciphertext character strings, digit it is minimum for 32, then when random number is generated,
In addition to ensureing more than 0,32 are also less than.That is, the maximum that the random number of generation can be got is 31, by
Cannot get identical with ciphertext character string digit or more than the number of ciphertext character string digit in the random number for generating
Value, so, according to each random number is generated, respectively when the every kind of ciphertext character string for obtaining is intercepted,
A complete ciphertext character string can not be truncated to, a part of word can only be intercepted in every kind of ciphertext character string
Symbol.
It is in practical application scene, as the digit of encrypted result finally to be obtained should not be too short, also unsuitable
It is long, therefore, encryption device can be before character be intercepted, it is determined that the digit of encrypted result to be obtained.
Specifically, encryption device can be according at least two ciphertext character strings for obtaining, it is determined that encryption to be obtained
As a result digit, also, in order to ensure each ciphertext character string is comprised only in the encrypted result for finally giving
A part of character, the digit of the encrypted result to be obtained that encryption device determines are smaller than at least two ciphertext
The digit sum of character string.In addition, encryption device is after the digit for determining encrypted result to be obtained,
When intercepting character, each random number sum of generation also will be with the digit phase of the encrypted result to be obtained for determining
Deng.
Continue to use the example above, by the plaintext string " drami890 " for obtaining by MD5 and SHA1 two
Kind of AES obtains two kinds of ciphertext character strings after being encrypted respectively, the digit of both ciphertext character strings it
With for 66, then encryption device it is determined that encrypted result to be obtained digit when, determined by digit be less than
Two kinds of ciphertext character string sums 66.Hypothesis determines that the digit of encrypted result to be obtained is 46, then generate
Each random number sum be also equal to 46.Assume to generate altogether 3 randoms number, respectively 8,22,16,
It is that 3 randoms number are added and be 46, and this 3 randoms number are all higher than 0, and it is less than two ciphertext characters
Minima 32 in the digit of string.
After each random number is generated, encryption device can then be directed to each random number, close at least two for obtaining
Select a kind of in Chinese character string, character, the number of the character of intercepting are arbitrarily intercepted from the ciphertext character string for selecting
The numerical value for the random number is measured, as shown in Figure 2.
The encryption device intercepting in the every kind of ciphertext character string for obtaining respectively that Fig. 2 is provided for the embodiment of the present application
The schematic diagram of character.
In Fig. 2, by the plaintext string " drami890 " for obtaining by two kinds of encryptions of MD5 and SHA1
Algorithm obtains as shown in Figure 2 two kind ciphertext character string after being encrypted respectively, obtaining two kinds of ciphertext characters
After string, encryption device determines that the digit of encrypted result to be obtained is 46, and when intercepting character is carried out,
3 randoms number are generated respectively:8、22、16.
As shown in Fig. 2 being directed to random number 8, it is assumed that the ciphertext character string of selection is to be calculated by md5 encryption
The ciphertext character string that method is obtained after being encrypted, then intercept front 8 characters, i.e. " w in the ciphertext character string
oeijoc1”。
Similar, for random number 22, it is assumed that the ciphertext character string of selection is to be entered by SHA1 AESs
The ciphertext character string that obtains after row encryption, then intercept front 22 characters, i.e. " xxi in the ciphertext character string
fmeng3255die5234fec”;For random number 16, it is assumed that the ciphertext character string of selection is by MD5
The ciphertext character string that AES is obtained after being encrypted, then 16 words after intercepting in the ciphertext character string
Symbol, i.e., " oiej333gienpmxde ".
In above-mentioned interception way, the character of intercepting be not required for must be in ciphertext character string one section it is continuous
Character, it is also possible to according to the numerical value of random number, the random intercepting equal number in corresponding ciphertext character string
Character.
S104:According to the character being truncated to, the encrypted result being encrypted to the plaintext string is obtained.
Encryption device is truncated to after character from each ciphertext character string by above-mentioned steps S103, will can be intercepted
To character be combined, the result of combination is used as the encryption knot being encrypted to the plaintext string for obtaining
Really.
Continue to use the example above, the 3 sections of characters for intercepting respectively are combined, obtain in each ciphertext character string
Combined result " woeijoc1xxifmeng3255die5234fecoiej333gienpmxde ", and the combination is tied
The encrypted result that fruit is obtained after being encrypted as the plaintext string " drami890 " to obtaining.
It should be noted that the mode for being combined the character being truncated to is not unique, when being combined,
The each character for intercepting can be carried out random combine, obtain the encrypted result that plaintext string is encrypted.
It is encrypted obtain by different AESs by including in the encrypted result that said method is obtained
Ciphertext character string, and the ciphertext character string for being included not is complete ciphertext character string, but intercept
The character string of the incompleteness for arriving, the complete ciphertext character obtained after being encrypted with respect to single AES
For string, can effectively prevent encrypted result from attack is compared by collision attack, brute force attack or rainbow table and be broken
Solution, so as to improve the safety of encrypted result.
Lower mask body is carried out so that plaintext string is for standard plaintext string and plaintext string to be certified as an example
Describe in detail.
In the scene for arranging password, the plaintext string of user input can be described as standard plaintext string, then
Encryption device is encrypted and obtains encrypted result to the standard plaintext string by method as shown in Figure 1
Afterwards, can preserve the encrypted result as standard ciphertext result, and preservation is carried out to the standard plaintext string
At least two AESs adopted during encryption, preserve the intercepting character when institute in every kind of ciphertext character string respectively
Using interception way, in case subsequent authentication use.
In the scene of cipher authentication, the plaintext string of user input can be described as plaintext string to be certified,
Then when being encrypted to the plaintext string to be certified by method as shown in Figure 1, in step S102
In, encryption device can be right using at least two AES corresponding with the standard ciphertext result for pre-saving
The plaintext string to be certified is encrypted, in step s 103, encryption device can using with pre-save
The corresponding interception way of standard ciphertext result, intercept character in the every kind of ciphertext character string for obtaining respectively.
Follow-up, encryption device is according to adding that the character being truncated to obtains being encrypted the plaintext string to be certified
After close result, using the encrypted result for obtaining as ciphertext result to be certified, and the ciphertext to be certified can be judged
Whether as a result identical with the standard ciphertext result for pre-saving, if so, then verification passes through, and otherwise, verification is not
Pass through.
For example, user is input into one section of plaintext string " ljq123bbb ", encryption when login password is arranged
Device is then using the plaintext string as standard plaintext string.Encryption device is receiving the standard plaintext word
After symbol string, which will be encrypted, wherein, encryption device is random from the multiple encryption algorithms for pre-saving
Choose two kinds of AESs of MD5 and SHS to be encrypted the standard plaintext string, respectively obtain corresponding
Two kinds of ciphertext character strings, and generate 3 randoms number:12nd, 7,14, for random number 12, select
Front 12 characters are intercepted during the ciphertext character string for obtaining is encrypted by SHS AESs;For random
Number 7, selection intercept front 7 words in the ciphertext character string for obtaining is encrypted by md5 encryption algorithm
Symbol;For random number 14, select in the ciphertext character string for obtaining is encrypted by md5 encryption algorithm
14 characters after intercepting, will intercept the sequence according to above-mentioned 3 randoms number of the character that obtains (that is, 12,7,
14) it is combined, the ciphertext character string for obtaining is standard ciphertext result, and the standard ciphertext result is preserved
In encryption device, meanwhile, encryption device will also be preserved to be encrypted the standard plaintext string and be adopted
AES, i.e. two kinds of AESs of MD5 and SHS;Preserve above-mentioned 3 randoms number 12,7,14
And, according to this 3 randoms number, adopted when intercepting character in above two ciphertext character string respectively
Interception way;Preserve the mode that the character that intercepting is obtained is combined.
And when user is when being logged in, then need by certification, i.e. one section of plaintext string of user input,
Encryption device then using the plaintext string as plaintext string to be certified, wait to recognize receiving this by encryption device
Card plaintext string when, the plaintext string to be certified will be encrypted, wherein encryption device using with guarantor
The corresponding AES of above-mentioned standard ciphertext result deposited is encrypted to the plaintext string to be certified, that is, adopt
It is encrypted with two kinds of AESs of MD5 and SHS, respectively obtains two kinds of ciphertext character strings;Encryption device
Using 3 randoms number (i.e. 12,7,14) corresponding with the above-mentioned standard ciphertext result for preserving, respectively upper
Character is intercepted in stating two kinds of ciphertext character strings, during intercepting, is obtained being encrypted by SHS AESs
Ciphertext character string in intercept front 12 characters, the ciphertext for obtaining is being encrypted by md5 encryption algorithm
Front 7 characters are intercepted in character string, the ciphertext character string that obtains is being encrypted by md5 encryption algorithm
14 characters after middle intercepting;Encryption device is using combination side corresponding with the above-mentioned standard ciphertext result for preserving
Formula, the intercepted character for obtaining is combined, i.e. by the clooating sequence of random number 12,7,14, will
The character being accordingly truncated to is combined, and the ciphertext character string for obtaining is ciphertext result to be certified.
Due to adopting identical encryption side for above-mentioned standard plaintext string and plaintext string to be certified
Method is encrypted, therefore, if standard plaintext string is identical with plaintext string to be certified, obtain
Standard ciphertext result and ciphertext result to be certified must be identical, whereas if standard plaintext string
Different with plaintext character to be certified, then the standard ciphertext result for obtaining is different with ciphertext result to be certified, also
It is to say, if standard plaintext string is identical with plaintext string to be certified, certification passes through, if standard
Plaintext string is different with plaintext character to be certified, then certification does not pass through.
The encryption method for providing for the embodiment of the present application above, based on same thinking, the embodiment of the present application is also
A kind of device of encryption is provided, as shown in Figure 3.
The structural representation of the encryption device that Fig. 3 is provided for the embodiment of the present application, specifically includes:
Acquisition module 301, for obtaining plaintext string;
Encrypting module 302, for being encrypted to the plaintext string using at least two AESs,
Obtain corresponding at least two ciphertexts character string;
Interception module 303, for intercepting character in the every kind of ciphertext character string for obtaining respectively;
Encrypted result obtains module 304, and according to the character being truncated to, acquisition is carried out to the plaintext string
The encrypted result of encryption.
The encrypting module 302 is additionally operable to, in the interception module 303 respectively in the every kind of ciphertext word for obtaining
Before character is intercepted on symbol string, according at least two ciphertexts character string for obtaining, it is determined that to be obtained adds
The digit of close result, wherein, the digit of the encrypted result to be obtained is less than at least two ciphertexts word
The digit sum of symbol string.
The interception module 303 is specifically for generating several randoms number more than 0, according to each of generation
Random number, intercepts character respectively in the every kind of ciphertext character string for obtaining;Wherein, each random number of generation it
With the digit equal to the encrypted result to be obtained, each random number respectively less than at least two ciphertexts word
Minima in the digit of symbol string.
The interception module 303 is specifically for for each random number, close in described at least two for obtaining
Select a kind of in Chinese character string, it is random from the ciphertext character string for selecting to intercept character, the number of the character of intercepting
Measure as the random number.
The encrypted result obtain module 304 specifically for, the character that obtains will be intercepted and is combined, as
The encrypted result is encrypted by the plaintext string for obtaining.
The plaintext string is standard plaintext string.
Described device also includes:
Preserving module 305, for preserving the encrypted result as standard ciphertext result, and preserves to institute
At least two AESs adopted when the standard plaintext string of stating is encrypted, preserve respectively in every kind of ciphertext
The interception way adopted when intercepting character in character string.
The plaintext string is plaintext string to be certified.
The encrypting module 302 is specifically for using corresponding at least with the standard ciphertext result for pre-saving
Two kinds of AESs, are encrypted to the plaintext string to be certified.
The interception module 303 is specifically for adopting intercepting corresponding with the standard ciphertext result for pre-saving
Mode, intercepts character respectively in the every kind of ciphertext character string for obtaining.
Described device also includes:
Correction verification module 306, for will obtain the encrypted result as ciphertext result to be certified;Judge institute
Whether state ciphertext result to be certified identical with the standard ciphertext result for pre-saving;If so, then verification passes through;
Otherwise, verification does not pass through.
The embodiment of the present application provides a kind of method and device of encryption, and the method is adopted to the plaintext string for obtaining
It is encrypted with least two AESs, obtains corresponding at least two ciphertexts character string, obtaining respectively
Every kind of ciphertext character string on intercept character, and according to the character being truncated to, obtain to the plaintext string
The encrypted result being encrypted.The encrypted result obtained by said method carries out adding comprising different AESs
The close ciphertext character string for obtaining, and the ciphertext character string for being included not is complete ciphertext character string, and
It is the character string for intercepting the incompleteness for obtaining, what is obtained after being encrypted with respect to single AES is complete
For ciphertext character string, can effectively prevent encrypted result from being attacked against each other by collision attack, brute force attack or rainbow table ratio
Hit and cracked, so as to improve the safety of encrypted result.
In a typical configuration, computing device includes one or more processors (CPU), input/defeated
Outgoing interface, network interface and internal memory.
Internal memory potentially includes the volatile memory in computer-readable medium, random access memory
And/or the form, such as read only memory (ROM) or flash memory (flashRAM) such as Nonvolatile memory (RAM).
Internal memory is the example of computer-readable medium.
Computer-readable medium include permanent and non-permanent, removable and non-removable media can by appoint
What method or technique is realizing information Store.Information can be computer-readable instruction, data structure, program
Module or other data.The example of the storage medium of computer includes, but are not limited to phase transition internal memory
(PRAM), static RAM (SRAM), dynamic random access memory (DRAM), its
The random access memory (RAM) of his type, read only memory (ROM), electrically erasable are read-only
Memorizer (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read only memory
(CD-ROM), digital versatile disc (DVD) or other optical storages, magnetic cassette tape, tape magnetic
Disk storage or other magnetic storage apparatus or any other non-transmission medium, can be used for storage can be calculated
The information that equipment is accessed.Define according to herein, computer-readable medium does not include temporary computer-readable matchmaker
The data signal and carrier wave of body (transitory media), such as modulation.
Also, it should be noted that term " including ", "comprising" or its any other variant are intended to non-row
His property is included, so that a series of process, method, commodity or equipment including key elements not only includes
Those key elements, but also including other key elements being not expressly set out, or also include for this process,
The intrinsic key element of method, commodity or equipment.In the absence of more restrictions, " included by sentence
One ... " key element that limits, it is not excluded that in the process including the key element, method, commodity or set
Also there is other identical element in standby.
It will be understood by those skilled in the art that embodiments herein can be provided as method, system or computer journey
Sequence product.Therefore, the application can using complete hardware embodiment, complete software embodiment or combine software and
The form of the embodiment of hardware aspect.And, the application can wherein include calculating using at one or more
Machine usable program code computer-usable storage medium (including but not limited to disk memory, CD-ROM,
Optical memory etc.) on the form of computer program implemented.
Embodiments herein is the foregoing is only, the application is not limited to.For this area skill
For art personnel, the application can have various modifications and variations.All institutes within spirit herein and principle
Any modification, equivalent substitution and improvements of work etc., within the scope of should be included in claims hereof.