Specific embodiment
To keep the purposes, technical schemes and advantages of the application clearer, below in conjunction with the application specific embodiment and
Technical scheme is clearly and completely described in corresponding attached drawing.Obviously, described embodiment is only the application one
Section Example, instead of all the embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not doing
Every other embodiment obtained under the premise of creative work out, shall fall in the protection scope of this application.
Fig. 1 is the process of encryption provided by the embodiments of the present application, specifically includes the following steps:
S101: plaintext string is obtained.
In the embodiment of the present application, encryption device obtains the plaintext string to be encrypted first.Specifically, encryption device can
The character string for determining user's input, as the plaintext string to be encrypted got.Wherein, user can be defeated when password is arranged
Enter plaintext string, then the plaintext string can be described as standard plaintext string, and user can also input plaintext character in verification
String, then the plaintext string can be described as plaintext string to be certified.The encryption device can be terminal, can also service
Device.
S102: the plaintext string is encrypted using at least two Encryption Algorithm, obtains corresponding at least two
Ciphertext character string.
After encryption device gets plaintext string, at least two can be selected from the multiple encryption algorithms pre-saved
Kind Encryption Algorithm, and the plaintext string is encrypted using at least two Encryption Algorithm selected, it obtains accordingly extremely
Few two kinds of ciphertext character strings.
Wherein, used at least two Encryption Algorithm can be randomly chooses in the multiple encryption algorithms pre-saved
Out.The multiple encryption algorithms pre-saved may include such as the 5th edition (Mes sage-Digest of message digest algorithm
Algorithm 5, MD5), Secure Hash Algorithm 1 (Secure Hash Algorithm 1, SHA1) and safe gibberish mark
Encryption Algorithm such as quasi- (Secure Hash Standard, SHS).For example, it is assumed that the plaintext string that encryption device obtains is
" drami890 " randomly selects the two different Encryption Algorithm of MD5 and SHA1, then in the multiple encryption algorithms pre-saved
Plaintext string " drami890 " can be encrypted by the md5 encryption algorithm of selection, obtain ciphertext character string
" woeijoc123s oijesoiej333gienpmxde ", by the SHA1 Encryption Algorithm of selection to plaintext string
" drami890 " is encrypted, and is obtained ciphertext character string " xxifmeng3255die5234fecj7hntu9dqafh ", is being obtained
After different ciphertext character strings, encryption device will be handled different ciphertext character strings.
S103: character is intercepted in every kind of obtained ciphertext character string respectively.
After obtaining different ciphertext character strings, encryption device will intercept character in each ciphertext character string, for passing through
For every kind of ciphertext character string that different Encryption Algorithm obtains, the character of interception is not complete ciphertext character string, that is,
When being intercepted for a kind of ciphertext character string, the partial character in the ciphertext character string is only intercepted.
Specifically, when intercepting character in each ciphertext character string, it is random greater than 0 can first to generate several for encryption device
Number, further according to each random number of generation, intercepts character in every kind of obtained ciphertext character string respectively.Further, in basis
When random number intercepts character, it can be directed to each random number, select one kind at least two obtained ciphertext character strings, then from choosing
Character is intercepted in the ciphertext character string selected at random, the quantity of the character of interception is exactly the random number.
In order to guarantee only to intercept each of a part of character, encryption device generation in a ciphertext character string in interception
Random number is smaller than the minimum value in the digit of at least two ciphertexts character string.
Continue to use the example above, the plaintext string " drami890 " that will acquire obtains after being encrypted by Encryption Algorithm MD5
Digit to ciphertext character string is 32, and the digit that ciphertext character string is obtained after being encrypted by SHA1 is 34, close at the two
In text character string, the smallest digit is 32, then when generating random number, in addition to guaranteeing to be greater than 0, is also less than 32.That is, generate
The maximum value that random number can be got is 31, since the random number of generation can not be got identical as ciphertext character string digit or be greater than close
The numerical value of text character string digit, so, according to each random number is generated, intercepted respectively in every kind of obtained ciphertext character string
When, it can not be truncated to a complete ciphertext character string, a part of character can only be intercepted in every kind of ciphertext character string.
It is also unsuitable too long since the digit for the encrypted result finally to be obtained is unsuitable too short in practical application scene, because
This, encryption device can be before intercepting character, the digit of the determination encrypted result to be obtained.
Specifically, encryption device can according at least two obtained ciphertext character strings, the determination encrypted result to be obtained
Digit, also, in order to guarantee a part of character for containing only each ciphertext character string in finally obtained encrypted result, encryption dress
The digit for setting the determining encrypted result to be obtained is smaller than the sum of the digit of at least two ciphertexts character string.In addition, encryption
Device is after the digit that the encrypted result to be obtained has been determined, when intercepting character, the sum of each random number of generation also will with it is true
The digit of the fixed encrypted result to be obtained is equal.
Continue to use the example above, the plaintext string " drami890 " that will acquire passes through two kinds of Encryption Algorithm of MD5 and SHA1 point
Two kinds of ciphertext character strings are obtained after not encrypted, the sum of digit of both ciphertext character strings is 66, then encryption device is true
When the digit for the encrypted result to be obtained surely, identified digit is less than the sum of two kinds of ciphertext character strings 66.Assuming that determining
The digit for the encrypted result to be obtained is 46, then the sum of each random number generated is also equal to 46.Assuming that generating 3 altogether at random
Number, respectively 8,22,16 are that 3 random numbers are added and be 46, and this 3 random numbers are all larger than 0, and less than two ciphertexts
Minimum value 32 in the digit of character string.
After generating each random number, encryption device can then be directed to each random number, at least two obtained ciphertext characters
One kind is selected in string, character is arbitrarily intercepted from the ciphertext character string of selection, and the quantity of the character of interception is the number of the random number
Value, as shown in Figure 2.
Fig. 2 is that encryption device provided by the embodiments of the present application intercepts character in every kind of obtained ciphertext character string respectively
Schematic diagram.
In Fig. 2, the plaintext string " drami890 " that will acquire is added respectively by two kinds of Encryption Algorithm of MD5 and SHA1
Two kinds of ciphertext character strings as shown in Figure 2 are obtained after close, after obtaining two kinds of ciphertext character strings, encryption device is determined to obtain
The digit of encrypted result be 46, and when carrying out interception character, generate 3 random numbers respectively: 8,22,16.
As shown in Fig. 2, being directed to random number 8, it is assumed that after the ciphertext character string selected is is encrypted by md5 encryption algorithm
" woeijoc1 " obtained ciphertext character string then intercepts preceding 8 characters, i.e., in the ciphertext character string.
Similar, for random number 22, it is assumed that after the ciphertext character string selected is is encrypted by SHA1 Encryption Algorithm
Obtained ciphertext character string then intercepts preceding 22 characters, i.e. " xxi in the ciphertext character string
fmeng3255die5234fec";For random number 16, it is assumed that the ciphertext character string selected is is added by md5 encryption algorithm
The ciphertext character string obtained after close, then 16 characters, i.e. " oiej333gienpmxde " after being intercepted in the ciphertext character string.
In above-mentioned interception way, the character of interception is not required for being one section of continuous character in ciphertext character string,
The character of identical quantity can also be intercepted at random in corresponding ciphertext character string according to the numerical value of random number.
S104: according to the character being truncated to, the encrypted result encrypted to the plaintext string is obtained.
Encryption device is after S103 is truncated to character from each ciphertext character string through the above steps, the character that can will be truncated to
It is combined, combined result is as the encrypted result encrypted to the plaintext string obtained.
Continue to use the example above, the 3 sections of characters intercepted in each ciphertext character string respectively are combined, combined result is obtained
" woeijoc1xxifmeng3255die5234fecoiej333gienpmxde ", and using the combined result as to the bright of acquisition
The encrypted result that text character string " drami890 " obtains after being encrypted.
It should be noted that the mode that the character being truncated to is combined is not unique, when being combined, can will cut
Each character taken carries out random combine, to obtain the encrypted result for encrypting plaintext string.
Pass through the ciphertext word in encrypted result obtained by the above method comprising being encrypted by different Encryption Algorithm
Symbol string, and the ciphertext character string for being included not is complete ciphertext character string, but the incomplete character string that interception obtains,
For the complete ciphertext character string obtained after being encrypted by single Encryption Algorithm, encrypted result quilt can be effectively prevent
Collision attack, brute force attack or rainbow table compare attack and are cracked, to improve the safety of encrypted result.
Lower mask body carries out specifically so that plaintext string is standard plaintext string and plaintext string to be certified as an example
It is bright.
In the scene of setting password, the plaintext string of user's input can be described as standard plaintext string, then encrypts dress
It sets after being encrypted to the standard plaintext string by method as shown in Figure 1 and obtain encrypted result, which can be tied
Fruit saves as standard ciphertext result, and saves at least two encryptions used when encrypting to the standard plaintext string and calculate
Method saves the used interception way when intercepting character in every kind of ciphertext character string respectively, in case subsequent authentication uses.
In the scene of cipher authentication, the plaintext string of user's input can be described as plaintext string to be certified, then logical
When crossing method as shown in Figure 1 and being encrypted to the plaintext string to be certified, in step s 102, encryption device can be used with
Corresponding at least two Encryption Algorithm of standard ciphertext result pre-saved, encrypts the plaintext string to be certified, In
In step S103, interception way corresponding with the standard ciphertext result pre-saved can be used in encryption device, is obtaining respectively
Character is intercepted in every kind of ciphertext character string.Subsequent, encryption device is obtained according to the character being truncated to the plaintext word to be certified
It, can be using the encrypted result of acquisition as ciphertext to be certified as a result, and judging to be somebody's turn to do wait recognize after the encrypted result that symbol string is encrypted
Whether card ciphertext result and the standard ciphertext result pre-saved are identical, if so, verification passes through, otherwise, verification does not pass through.
For example, user when login password is arranged, inputs one section of plaintext string " ljq123bbb ", encryption device then will
The plaintext string is as standard plaintext string.Encryption device will carry out it after receiving the standard plaintext string
Encryption, wherein encryption device randomly selects two kinds of Encryption Algorithm of MD5 and SHS to this from the multiple encryption algorithms pre-saved
Standard plaintext string is encrypted, and respectively obtains corresponding two kinds of ciphertext character strings, and generates 3 random numbers: 12,7,14,
For random number 12, selection intercepts preceding 12 characters in the ciphertext character string encrypted by SHS Encryption Algorithm;Needle
To random number 7, selection intercepts preceding 7 characters in the ciphertext character string encrypted by md5 encryption algorithm;For with
Machine number 14,14 characters after selection intercepts in the ciphertext character string encrypted by md5 encryption algorithm, will intercept
To character be combined according to the sequence (that is, 12,7,14) of above-mentioned 3 random numbers, obtained ciphertext character string be standard it is close
Text as a result, and the standard ciphertext result is stored in encryption device, meanwhile, encryption device will also be saved to the standard plaintext word
Symbol string carries out encrypting used Encryption Algorithm, i.e. two kinds of Encryption Algorithm of MD5 and SHS;Save above-mentioned 3 random numbers 12,7,14
And according to this 3 random numbers, used interception way when character is intercepted in above two ciphertext character string respectively;It protects
Deposit the mode for being combined the character that interception obtains.
And when user is when logging in, then it needs through certification, i.e. user inputs one section of plaintext string, encryption device
Then using the plaintext string as plaintext string to be certified, encryption device, will when receiving the plaintext string to be certified
The plaintext string to be certified is encrypted, wherein encryption device is added using corresponding with the above-mentioned standard ciphertext result of preservation
Close algorithm encrypts the plaintext string to be certified, i.e., is encrypted using two kinds of Encryption Algorithm of MD5 and SHS, respectively
To two kinds of ciphertext character strings;Encryption device using 3 random numbers corresponding with the above-mentioned standard ciphertext result of preservation (i.e. 12,7,
14) character, is intercepted in above two ciphertext character string respectively, when interception, what is encrypted by SHS Encryption Algorithm
Preceding 12 characters are intercepted in ciphertext character string, and preceding 7 are intercepted in the ciphertext character string encrypted by md5 encryption algorithm
Position character, 14 characters after being intercepted in the ciphertext character string encrypted by md5 encryption algorithm;Encryption device uses
Combination corresponding with the above-mentioned standard ciphertext result of preservation, the character intercepted is combined, that is, presses random number
12, the character being accordingly truncated to is combined by 7,14 collating sequence, and obtained ciphertext character string is ciphertext knot to be certified
Fruit.
It is carried out due to being all made of identical encryption method for above-mentioned standard plaintext string and plaintext string to be certified
Encryption, therefore, if standard plaintext string is identical with plaintext string to be certified, obtained standard ciphertext result and to
Certification ciphertext result must be identical, whereas if standard plaintext string and plaintext character difference to be certified, then obtain
Standard ciphertext result is different with ciphertext result to be certified, that is to say, that if standard plaintext string and plaintext character to be certified
Go here and there identical, then certification passes through, if standard plaintext string and plaintext character to be certified are different, authenticate and does not pass through.
The above are encryption methods provided by the embodiments of the present application, are based on same thinking, and the embodiment of the present application also provides one
The device of kind encryption, as shown in Figure 3.
Fig. 3 is the structural schematic diagram of encryption device provided by the embodiments of the present application, is specifically included:
Module 301 is obtained, for obtaining plaintext string;
Encrypting module 302 is obtained corresponding for being encrypted using at least two Encryption Algorithm to the plaintext string
At least two ciphertext character strings;
Interception module 303, for intercepting character in every kind of obtained ciphertext character string respectively;
Encrypted result obtains module 304, according to the character being truncated to, obtains and adds to what the plaintext string was encrypted
Close result.
The encrypting module 302 is also used to, and is cut in every kind of obtained ciphertext character string respectively in the interception module 303
Before taking character, according to the obtained at least two ciphertexts character string, the digit of the determination encrypted result to be obtained, wherein
The digit of the encrypted result to be obtained is less than the sum of the digit of at least two ciphertexts character string.
The interception module 303 is specifically used for, and generates several random numbers for being greater than 0, according to each random number of generation, divides
Character is not intercepted in every kind of obtained ciphertext character string;Wherein, what the sum of each random number of generation to be obtained equal to described in adds
The digit of close result, each random number are respectively less than the minimum value in the digit of at least two ciphertexts character string.
The interception module 303 is specifically used for, for each random number, in the obtained at least two ciphertexts character string
In select one kind, intercept character at random from the ciphertext character string of selection, the quantity of the character of interception is the random number.
The encrypted result obtains module 304 and is specifically used for, and the character that interception obtains is combined, pair as acquisition
The encrypted result that the plaintext string is encrypted.
The plaintext string is standard plaintext string.
Described device further include:
Preserving module 305 for saving the encrypted result as standard ciphertext result, and saves bright to the standard
At least two Encryption Algorithm used when text character string is encrypted save respectively when intercepting character in every kind of ciphertext character string
Used interception way.
The plaintext string is plaintext string to be certified.
The encrypting module 302 is specifically used for, and adds using with the standard ciphertext result corresponding at least two pre-saved
Close algorithm encrypts the plaintext string to be certified.
The interception module 303 is specifically used for, and using interception way corresponding with the standard ciphertext result pre-saved, divides
Character is not intercepted in every kind of obtained ciphertext character string.
Described device further include:
Correction verification module 306, the encrypted result for that will obtain is as ciphertext result to be certified;Judge described to be certified
Whether ciphertext result and the standard ciphertext result pre-saved are identical;If so, 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 this method is to the plaintext string of acquisition using at least
Two kinds of Encryption Algorithm are encrypted, and corresponding at least two ciphertexts character string is obtained, respectively in every kind of obtained ciphertext character string
Upper interception character, and according to the character being truncated to, obtain the encrypted result encrypted to the plaintext string.By above-mentioned
The ciphertext character string that the encrypted result that method obtains is encrypted comprising different Encryption Algorithm, and the ciphertext word for being included
Symbol string is not complete ciphertext character string, but the incomplete character string that interception obtains, relative to passing through single Encryption Algorithm
For the complete ciphertext character string obtained after being encrypted, encrypted result can be effectively prevent by collision attack, brute force attack or coloured silk
Rainbow table compares attack and is cracked, to improve the safety of encrypted result.
In a typical configuration, calculating equipment includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flashRAM).Memory is showing for computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
It include so that the process, method, commodity or the equipment that include a series of elements not only include those elements, but also to wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including described want
There is also other identical elements in the process, method of element, commodity or equipment.
It will be understood by those skilled in the art that embodiments herein can provide as method, system or computer program product.
Therefore, complete hardware embodiment, complete software embodiment or embodiment combining software and hardware aspects can be used in the application
Form.It is deposited moreover, the application can be used to can be used in the computer that one or more wherein includes computer usable program code
The shape for the computer program product implemented on storage media (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)
Formula.
The above description is only an example of the present application, is not intended to limit this application.For those skilled in the art
For, various changes and changes are possible in this application.All any modifications made within the spirit and principles of the present application are equal
Replacement, improvement etc., should be included within the scope of the claims of this application.