Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "string.h"
- #include "stdafx.h"
- int _tmain(int argc, _TCHAR* argv[])
- {
- char password[ 1024 ];
- int hexChar2int(char c)
- {
- if(c >= 'A' && c <= 'F')
- return c - 'A' + 10;
- else if(c >= 'a' && c <= 'f')
- return c - 'a' + 10;
- else if(c >= '0' && c <= '9')
- return c - '0';
- return 0;
- }
- void decodePassword( const char *pass, const char *key )
- {
- unsigned int n1, n2;
- typedef unsigned short ushort;
- int password_index = 0;
- unsigned char c;
- //if(key.length() == 0)
- //return pass;
- for( n1 = 0, n2 = 0; n1 < strlen( pass ); n1 += 4 )
- {
- ushort x = 0;
- if(n1 + 4 > strlen( pass ) )
- break;
- x += hexChar2int( pass[ n1 ] ) * 4096;
- x += hexChar2int( pass[ n1+1 ] ) * 256;
- x += hexChar2int( pass[ n1+2 ] ) * 16;
- x += hexChar2int( pass[ n1+3 ] );
- c = ( unsigned char )( x ^ key[ n2++ ] );
- password[ password_index++ ] = c;
- if( n2 > strlen( key ) )
- n2 = 0;
- }
- }
- int main( void )
- {
- decodePassword( "Encrypted password from config.xml here", "user_name@jabber.org" );
- printf( "Password:%s\n", password );
- return 0;
- }
- }
Add Comment
Please, Sign In to add comment