31.MD5 encryption

Say first: MD5 encryption can be cracked, each of the original password corresponding to an unchanged MD5 encryption password,
effect:

MD5 encryption demo password: c1j2

31.MD5 encryption
MD5 encryption

I. brief MD5:

  • 1.MD5, that is, Message-Digest Algorithm 5, is used to ensure complete and consistent transmission of information. Is one of the widely used hash algorithm of computer (also translated the abstract algorithm and hash algorithm), mainstream programming language generally have MD5 implementation. The role of MD5 is to make the large capacity information in the private key is signed with a digital signature software are compressed into a confidential format (is an arbitrary length byte string transform into a long string of sixteen hexadecimal numbers). (quoted from Baidu Encyclopedia)
  • 2.MD5 is not an encryption algorithm, but used for file verification. For example, the official release of a software, while publishing a MD5 checksum. If you downloaded the software, through the MD5 checksum, and the official announcement of the different, you have to explain this software has been modified, not the official original. The MD5 algorithms are unified, without keys or anything like that. The same string can be obtained from the same MD5 code after MD5 transcoding. However, MD5 is a digest algorithm that is irreversible, but can be decrypted online online, that is, the raw data cannot be restored through the MD5 value. Encryption, decryption, and so on, or DES/AES + BASE64 and other algorithms to achieve.

Two.MD5 usage

  • 1. in Objective-C we do for MD5 encryption, we first need to include the header file is #import < CommonCrypto/CommonDigest.h&gt digest; [da’d st] vt. digestion; absorption;
    crypto [‘kript u] adj. together. The secret, hidden, not open
  • In fact, the 2. usage with the simple, a method invocation (two methods)
    1. for the first [self md5:@ to encrypt something “]; / / you can print out is good string encryption, decryption can online – (NSString) md5: (NSString * STR) {const char cStr = [str * UTF8String]; unsigned char result[16]; CC_MD5 (cStr (CC_LONG) strlen (cStr), result); / / This is the MD5 call return [NSString stringWithFormat: @”%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x “, result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15]] second – 2.;} (NSString *) md5HexDigest: (NSString*) {password Const char *original_str = [password UTF8String]; unsigned char result[CC_MD5_DIGEST_LENGTH]; CC_MD5 (original_str, strlen (original_str), result); NSMutableString *hash = [NSMutableString string]; for (int i = 0; I < CC_MD5_DIGEST_LENGTH; i++) {/ *%02X is the format control characters: ‘x’ output to 16 hexadecimal, “02” said less than two, in front of 0 / [hash; appendFormat:@ “%02X” result[i]] NSString *mdfiveString lowercaseString] = [hash;}}; return mdfiveString; 1.char[16] and%02x: the origins of
    %02x which is the character of format control: “X” represents the output to 16 hexadecimal, “02” said less than two bits, such as in front of 0; the ‘f’ output is 0f, output “1f3” 1f3; originally in general will introduced here, I want to introduce the code in result is an array of characters, that is why [16], this is because the MD5 algorithm of last generation is 128, and in the smallest unit of storage for computer bytes, 1 bytes is 8, corresponding to a char type was calculated to be 16 char. So result is [16]. So, why does the output format have to be%02x, not something else?. This is a reason: because the agreement is generally MD5 to 16 hexadecimal output format, so in fact this problem is converted to the 128 to 0 and 1 to 16 hexadecimal representation, each 4 bits corresponding to a band of 16 elements, 32 to 16 hex elements, if all elements is 0. In the char array, the output is not normal, such as 00001111, the%x output is f, then you will lose 0; but if the%02x is output is 0f, the conversion is just right. (excerpt)
    2. for 16 bit MD5 encryption explanation
31.MD5 encryption

As for the
16 MD5 people say the encryption, fact is this: for example if MD5 encrypted string is generated: 01234567abcdefababcdefab76543210, MD 16 bit encryption characters is abcdefababcdefab, which is only 16 in the middle of the interception. In fact, this operation is no longer included in the MD5 encryption algorithm, but should be the two processing of the results of the MD5 encryption algorithm. The other 64 bits and sizes are the two for the MD5 algorithm. Because the result of the MD5 algorithm is 128bit, 128 binary digits.

Three. A brief introduction to encryption

* 1: simple concept, the plaintext before encryption ciphertext information: information confidential: after the encryption algorithm for encryption and decryption algorithm key algorithm: using the key (read: miyao, the right should be miyue, but we all read miyao) * simple example 123456 each figures with 1 after 234567, including the 123456 is 234567 is the plaintext, ciphertext, the encryption key is 1, each with 2 * encryption algorithm is the encryption algorithm encryption type, according to the way we can be divided into three kinds of encryption algorithm: * (symmetric encryption algorithm encryption and decryption algorithm is symmetric may be a bit abstract you can be understood as the same key) * (non symmetric encryption algorithm encryption and decryption algorithm is a non symmetric encryption can be understood as it is a key When decryption is the key that is typical of RSA public key and private key) * classic Hashi algorithm (Hashi algorithm is a hash algorithm, a special is that it is not reversible only through exhaustive method can calculate the super large amounts of calculation, the general probability is very small, there is a clear two with you the encryption result is not the same, for example, 3) * * * algorithm of symmetric encryption algorithm: DES algorithm, 3DES algorithm, TDEA algorithm, Blowfish algorithm, RC5 algorithm, IDEA algorithm, AES algorithm. * asymmetric encryption algorithms: RSA, Elgamal, knapsack algorithms, Rabin, D-H, ECC. * hash algorithm classic: MD2, MD4, MD5 and SHA-1 (* * to be arbitrarily long input through the algorithm into fixed length output, and ensures that the input point output changes are different, and can not reverse the decryption) * 4, today we look at our hair in the algorithm used only temporarily MD5, Base64, Sha, AES, RSA * RSA: encryption algorithm encryption * important algorithm in non symmetric encryption algorithm is probably the world's most important algorithm, it is the cornerstone of today's electronic commerce fields. In a nutshell, asymmetric encryption means that the encryption public key is different from the decryption key, and the encryption public key and the decryption key appear in pairs. Asymmetric encryption is also called public key encryption, i.e. pairwise key, one of which is open to the public, everyone can get, it is called public key; and correspondingly called private key, only the key generation could have. * for a private key, there is only one public key corresponding to it. The public key is publicly available to anyone, and the private key is usually owned only by the generator. The public / private key is usually 1024 bit or 2048 bit, and the longer the security factor is, the more difficult it is to decrypt. Despite getting the public key, it's almost impossible to decrypt if you don't have a private key. At least no one in the world now speaks publicly about successful decryption. * 5. first mobile terminal to the server through the transfer of RSA public key encrypted data, the key parameters including DES (eight bit key is randomly generated string) and related parameter information, the server decrypts the data information through the private key, which include the DES key and the related parameter information, the server then returns the data to the mobile by the DES key encryption terminal, mobile terminal to decrypt the data accessed by the DES key. * advantages: because the RSA is not easy to decrypt, even blocked decryption, get the key of DES, because the DES key is randomly generated, this time can only decrypt data information, does not affect other data. (Note: DES key every time we re randomly generated, which is a key to complete only this time the data transfer) * summary: public key and key pairs, which is responsible for public key encryption and decryption key for * * /

Four. Online encryption and decryption

  • 1 MD5 online encryption
31.MD5 encryption
  • 2 MD5 decryption
    , 31.MD5 encryption,
    , MD5, encryption,
    , 31.MD5 encryption,
  • 3 MD5 encryption and decryption
31.MD5 encryption

Remember to like it!!! Hey! Hey!