Modify the password string using the MD5 encoding class of others

xiaoxiao2021-03-06  24

Download an MD5 encoding class from the Internet, thanks to Robert Hubley

The strange thing is to enter a password. The output encoded function defines the following Void Md5Update (unsigned int inputlen); Void Md5Final (unsigned char digest [16]);

When entering the character array pointer and length, output a char [16] Normal MFC Enter the password obtained by cstring can only be converted // cstring m_input char a [100]; strncpy (a, m_input, sizeof (a) ); M_input.getlength ()); Md5Update ((unsigned char *) A, M_INPUT.GETLENGTH ()); use functions Strncpy to press M_Input into a [100]

When the output is output, you get Char [16], the discovery program actually modifies the value of the char unit, and the character is independent, equivalent to a shortint [16] Since the number encoding string of CString is required [string is inconvenient, in the ini file After storage, read it again] unsigned char pass1 [16]; md5final (pass1); cstract pass; pass.format ("% i% i% i% I% I% I% i% i% i% i) % I% I% I% I ", Pass1 [0], Pass1 [1], Pass1 [2], Pass1 [3], Pass1 [4], Pass1 [5], Pass1 [6], Pass1 [7 ], Pass1 [8], Pass1 [9], Pass1 [10], Pass1 [11], Pass1 [12], Pass1 [13], Pass1 [14], Pass1 [15]); // Return Pass;

Method is more stupid

Add the above to the downloaded class, you can

//md5.h file

/ ************************************************** *************************************** * CopyRight (c) 2000 by Robert Hubley. * * All Rights Reserved. * * * * This software is provided `` AS IS '' and any express or implied * * warranties, including, but not limited to, the implied warranties of * * merchantability and fitness for a particular purpose, are disclaimed. * * In no event shall the authors be liable for any direct, indirect, * * incidental, special, exemplary, or consequential damages (including, but * * not limited to, procurement of substitute goods or services; loss of use, * * data, or profits; or business interruption ) However caused and on any * * Theory of Liability, WHETHER IN Contract, Strict Liability, or Tort * * (Including negligence or otherwise) arising in A NY WAY OUT OF THE USE, EVEN IFTWARE, EVEN IFTWARE, EVEN IF Advised of The Possibility of Such Damage. * * * ********************************* *********************************************************** *** md5.h - Header File for MD5C.c Port to Win32 DLL by Robert Hubley 1/5/2000

Original Copyright:

Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All Rights Reserved.

License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing this software or this function.

License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes No representability of this software. ..................................

Sikiş sikiş sikiş sikiş 0668 *********************************************************** * Copyright (C) 2000 by Robert Hubley. * * All rights reserved. * * * * This software is provided `` AS IS '' and any express or implied * * warranties, including, but not limited to, the implied warranties of * * merchantability and fitness for a particular purpose, are disclaimed. * * In no event shall the authors be liable for any direct, indirect, * * incidental, special, exemplary, or consequential damages (including, but * * not limited to, Procurest of subs, * * data, or profits; or business interruption) However caused and on any * * theory of liability, WHether in contract, strict liability, or tort * * (including negligence or otherwise) arising in any way out of the use of * * this software, even if advised of the possibility of such damage. * * * ******* *********************************************************** *********************************************************** *********************************************************** ** * 2002-4-18 Modified by LiGuangyi.

* * Struct md5_ctx ==> Class MD5_CTX.

* * Take Off The globals functions * ************************************************** ********************************************* /

#ifndef _LGY_MD5_H # define _lgy_md5_h

/ * Md5 class. * / Class md5_ctx {public: md5_ctx (); Virtual ~ md5_ctx (); void md5Update (unsigned int infutlen); Void Md5Final (unsigned char digest [16]);

Private: unsigned long int state [4]; / ​​* state (abcd) * / unsigned long int count [2]; / * Number of Bits,

MODULO 2 ^ 64 (LSB first) * / unsigned char buffer [64]; / ​​* input buffer * / unsigned char Padding [64]; / ​​* what? * /

private: void MD5Init (); void MD5Transform (unsigned long int state [4], unsigned char block [64]); void MD5_memcpy (unsigned char * output, unsigned char * input, unsigned int len); void Encode (unsigned char * output, unsigned long int * input, unsigned int len); void Decode (unsigned long int * output, unsigned char * input, unsigned int len); void MD5_memset (unsigned char * output, int value, unsigned int len); public: CSTRING MAKEPASSMD5 (CSTRING M_INPUT);

#ENDIF

//md5.cpp file

/ ************************************************** **************************************** CopyRight (c) 2000 by Robert Hubley. ** All Rights Reserved. ** ** this software is provided `` AS IS '' and any express or implied ** warranties, including, but not limited to, the implied warranties of ** merchantability and fitness for a particular purpose, are disclaimed. ** In no event shall the authors be liable for any direct, indirect, ** incidental, special, exemplary, or consequential damages (including, but ** not limited to, procurement of substitute goods or services; loss of use, ** data, or profits; or business interruption ) However caused and on any ** theory of liability, WHETHER in contract, strict liability, or orwise) arising in Any Way Out O Fireware, Even if advised of the possibility of self damage. ** ****************************************************************************************************************************************************************************************************************************************************************** *********************************************************** MD5C.C - RSA Data Security, Inc., MD5 Message-Digest Algorithm

Port to Win32 DLL by Robert Hubley 1/5/2000

Original Copyright:

Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All Rights Reserved.

License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and / or software. * / # include // This sentence is very important !! # include "md5.h" #include "./md5.h"/* constants for md5transform routine. * / # define s11 7 # define s12 # define s13 17 #define s14 22 # Define S21 5 # Define S22 9 # Define S23 14 # Define S24 20 # Define S31 4 # Define S32 11 # Define S33 16 # Define S34 23 # Define S41 6 # Define S42 10 # Define S43 15 # Define S44 21

/ * F, g, h and i are Basic MD5 functions. * / # Define f (x, y, z) ((x) & (y)) | (~ x) & (z))) # define G (X, Y, Z) | ((Y) & (~ Z))) # define h (x, y, z) ((x) ^ (y) ^ ( Z) #DEFINE I (X, Y, Z) ((Y) ^ ((x) | (~ z))))

/ * Rotate_LEFT Rotates x left n bits. * / # Define rotate_left (x, n) ((x) << (n)) | ((x) >> (32- (n))))))

/ * FF, GG, HH, AND II Transformations for Rounds 1, 2, 3, and 4.Rotation is Separate from addition to prevent recomputation. * / # Define FF (A, B, C, D, X, S, AC ) {/ (A) = f ((b), (c), (d)) (x) (AC); / (a) = rotate_left ((a), (s) ); / (A) = (b); /} #define gg (A, B, C, D, X, S, AC) {/ (a) = g ((b), (c), D)) (x) (unsigned long int); / (a) = rotate_left ((a), (s)); / (a) = (b); /} #define hh (a , B, C, D, X, AC) {/ (a) = H ((b), (c), (D)) (x) (AC); / (( a) = rotate_left ((a), (s)); / (a) = (b); /} #define II (A, B, C, D, X, S, AC) {/ (a) = I ((b), (c), (d)) (x) (AC); / (a) = rotate_left ((a), (s)); / (a) = (b); /} / * md5 initialization. Begins an MD5 Operation, Writing a new context. * /

MD5_CTX :: MD5_CTX () {md5init ();

MD5_CTX :: ~ md5_ctx () {}

Void MD5_CTX :: Md5init () {this-> count [0] = this-> count [1] = 0; / * load magic initialization constants. * / this-> state [0] = 0x67452301; this-> state 1] = 0xefcdab89; this-> state [2] = 0x98badcfe; this-> state [3] = 0x10325476; / * add by LiGuangyi * / MD5_MEMSET (Padding, 0, Sizeof (Padding)); * Padding = 0x80; / / Padding = {// 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

. / * MD5 block update operation Continues an MD5 message-digestoperation, processing another message block, and updating thecontext * / void MD5_CTX :: MD5Update (unsigned char * input, unsigned int inputLen) {unsigned int i, index, partLen;. / * Compute Number of Bytes MOD 64 * / INDEX = ((this-> count [0] >> 3) & 0x3f); / * update number of bits * / if ((this-> count [0] = (unsigned long int) Inputlen << 3)) <((unsigned long int) infutlen << 3)) this-> count [1] ; this-> count [1] = ((unsigned long) INTLUTLEN >> 29); Partlen = 64 - Index; / * Transform As Many Times As Possible. * / if (Inputlen> = Partle) {MD5_Memcpy ((unsigned char *) & this-> buffer [index], (unsigned Char *) Input, Partle; MD5Transform (this-> State, this-> buffer); for (i = partlen; i 63 State, & Input [i]) ; Index = 0;} else i = 0; / * buffer recaining input * / md5_memcpy ((unsigned char *) & this-> buffer [index], (unsigned char *) & input [i], inputlen-i);}

/ * MD5 finalization Ends an MD5 message-digest operation, writing thethe message digest and zeroizing the context * / void MD5_CTX :: MD5Final (unsigned char digest [16]) {unsigned char bits [8];.. Unsigned int index, padLen ; / * Save Number of Bits * / Encode (Bits, this-> Count, 8); / * Pad out to 56 mod 64. * / index = (unsigned int) ((this-> count [0] >> 3 ) & 0x3f); Padlen = (INDEX <56)? (56 - index): (120 - index); md5Update (padding, padlen); / * append length (before padding) * / md5Update (BITS, 8); / * Store State In Digest * / Encode (Digest, this-> State, 16); / * ZEROIZE SENSITIVE INFORMATION. * / MD5_MEMSET ((unsigned char *) this, 0, sizeof (* this)); this-> md5init }

/ * MD5 Basic Transformation. * / Void MD5_CTX :: Md5Transform (unsigned long int state [4], unsigned char block [64]) {unsigned long int a = state [0], b = state 1], c = state [2], d = state [3], x [16]; decode (x, block, 64); / * runk 1 * / ff (a, b, c, d, x [0 ], S11, 0xD76AA478); / * 1 * / ff (D, A, B, C, X [1], S12, 0xE8C7B756); / * 2 * / ff (C, D, A, B, X [2 ], S13, 0x242070dB); / * 3 * / ff (B, C, D, A, X [3], S14, 0XC1BDCEEE); / * 4 * / FF (A, B, C, D, X [4 ], S11, 0xF57c0FAF); / * 5 * / ff (D, A, B, C, X [5], S12, 0X4787C62A); / * 6 * / ff (C, D, A, B, X [6 ], S13, 0xA8304613); / * 7 * / ff (B, C, D, A, X [7], S14, 0xFD469501); / * 8 * / ff (A, B, C, D, X [8 ], S11, 0x698098d8); / * 9 * / ff (D, A, B, C, X [9], S12, 0x8B44F7AF); / * 10 * / ff (C, D, A, B, X [10 ], S13, 0xFFFF5BB1); / * 11 * / ff (B, C, D, A, X [11], S14, 0x895CD7BE); / * 12 * / ff (A, B, C, D, X [12 ], S11, 0x6b901122); / * 13 * / ff (D, A, B, C, X [13], S12, 0xFD987193); / * 14 * / ff (C, D, A, B, X [14 ], S13, 0xA679438E); / * 15 * / ff (B, C, D, A, X [15], S14, 0X49B40821); / * 16 * / / * ROUND 2 * / GG (A, B, C, D, X [1], S21 0xF61E2562); / * 17 * / gg (D, A, B, C, X [6], S22, 0XC040B340); / * 18 * / gg (C, D, A, B, X [11], S23 0x265E5A51); / * 19 * / gg (B, C, D, A, X [0], S24, 0XE9B6C7AA); / * 20 * / gg (A, B, C, D, X [5], S21 0xD62F105D); / * 21 * / gg (D, A, B, C, X [10], S22, 0X2441453); / * 22 * ​​/ gg (C, D, A, B, X [15], S23 0xD8A1E681); / * 23 * / gg (B, C, D, A, X [4], S24, 0xE7D3FBC8); / * 24 * / gg (A, B, C, D, X [9], S21 0x21e1cde6); / * 25 * / gg (D, A, B, C, X [14], S22, 0XC33707D6); / * 26 * / gg (C, D, A, B, X [3], S23 0xF4D50D87); / * 27 * / gg (B, C, D, A, X [8], S24, 0x455A14ED); / * 28 * / gg (A, B, C, D, X [13], S21 0xA9E3E905);

/ * 29 * / gg (D, A, B, C, X [2], S22, 0XFCEFA3F8); / * 30 * / gg (C, D, A, B, X [7], S23, 0X676F02D9); / * 31 * / gg (B, C, D, A, X [12], S24, 0x8D2A4C8A); / * 32 * / / * Round 3 * / hh (A, B, C, D, X [5] , S31, 0xFFFA3942); / * 33 * / HH (D, A, B, C, X [8], S32, 0x8771F681); / * 34 * / HH (C, D, A, B, X [11] , S33, 0x6D9D6122); / * 35 * / hh (B, C, D, A, X [14], S34, 0xFDE5380C); / * 36 * / HH (A, B, C, D, X [1] , S31, 0xA4Beea44); / * 37 * / hh (D, A, B, C, X [4], S32, 0x4BDECFA9); / * 38 * / HH (C, D, A, B, X [7] , S33, 0XF6BB4B60); / * 39 * / HH (B, C, D, A, X [10], S34, 0XBEBFBC70); / * 40 * / HH (A, B, C, D, X [13] , S31, 0x289B7EC6); / * 41 * / HH (D, A, B, C, X [0], S32, 0xEAA127FA); / * 42 * / HH (C, D, A, B, X [3] S33, 0xD4ef3085); / * 43 * / hh (B, C, D, A, X [6], S34, 0x4881D05); / * 44 * / HH (A, B, C, D, X [9] , S31, 0XD9D4D039); / * 45 * / HH (D, A, B, C, X [12], S32, 0XE6DB99E5); / * 46 * / HH (C, D, A, B, X [15] , S33, 0x1FA27CF8); / * 47 * / HH (B, C, D, A, X [2], S34, 0XC4AC5665); / * 48 * / / * ROUND 4 * / II (A, B, C , D, X [0], S41, 0XF4292244); / * 49 * / II (D, A, B, C, X [7], S42, 0x432AFF97); / * 50 * / II (C, D, A , B, X [14], S43, 0XAB9423A7); / * 51 * / II (B, C, D, A, X [5], S44, 0XFC93A039); / * 52 * / II (A, B, C , D, X [12], S41, 0X655B59C3); / * 53 * / II (D, A, B, C, X [3], S42, 0x8F0CCC92); / * 54 * / II (C, D, A , B, X [10], S43, 0xffeff47d); / * 55 * / ii (B, C, D, A, X [1], S44, 0x85845DD1); / * 56 * / II (A, B, C , D, X [8], S41, 0X6FA87E4F); / * 57 * / II (D, A, B, C, X [15], S42, 0XFE2CE6E0); / * 58 * / II (C, D, A , B, X [6], S43, 0XA3014314); / * 59 * / II (B, C, D, A, X [13], S44, 0X4E0811A1); / * 60 * / II (A, B, C , D, X [4], S41, 0XF7537E82); / * 61 * / ii (D, A, B, C, X [11], S42, 0XBD3AF235); / * 62 * / II (C, D, A , B, X [2], S43, 0X2AD7D2BB);

/ * 63 * / ii (B, C, D, A, X [9], S44, 0XEB86D391); / * 64 * / state [0] = a; state [1] = b; state [2] = C; State [3] = D; / * ZEROIZE SENSITIVE INFORMATION. * / MD5_MEMSET ((unsigned char *) x, 0, sizeof (x));} / * Encodes Input (unsigned long int) ositPut ( Unsigned char). Assumes Len isa multiple of 4. * / void md5_ctx :: eNCode (unsigned char * outprut, unsigned length) {UNSIGNED INT i, J; For (i = 0, j = 0 J > 8) & 0xFF); OUTPUT [J 2] = (Unsigned Char) ((INPUT [I] >> 16) & 0xFF); Output [J 3] = (Unsigned Char) ((Input [i] >> 24) & 0xFF);}}

/ * Decodes input (unsigned char) into output (unsigned long int). Assumes len isa multiple of 4. * / Void MD5_CTX :: Decode (unsigned long int * output, unsigned char * input, unsigned int len) {unsigned int i , J; for (i = 0, j = 0; j

<< 8) | ((unsigned long int) INPUT [J 2]) << 16) | ((unsigned long int) INPUT [J 3])

<< 24);

/ * Note: Replace "for loop" with standard memcpy if Possible. * /

Void MD5_CTX :: MD5_MEMCPY (unsigned char * input, unsigned int LEN) {unsigned int i; for (i = 0; i

/ * NOTE: Replace "for loop" with standard memset if Possible. * / Void md5_ctx :: md5_memset (unsigned char * OUTPUT, INT VALUE, UNSIGNED INT LEN) {Unsigned Int i; for (i = 0; I

Call usage method is cstring num = md5_ctx :: makepassmd5 ("password")

转载请注明原文地址:https://www.9cbs.com/read-65525.html

New Post(0)