Guest User

Untitled

a guest
Nov 16th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.43 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "string.h"
  3. #include "stdafx.h"
  4.  
  5. int _tmain(int argc, _TCHAR* argv[])
  6. {
  7.  
  8. char password[ 1024 ];
  9.  
  10. int hexChar2int(char c)
  11. {
  12.         if(c >= 'A' && c <= 'F')
  13.                 return c - 'A' + 10;
  14.         else if(c >= 'a' && c <= 'f')
  15.                 return c - 'a' + 10;
  16.         else if(c >= '0' && c <= '9')
  17.                 return c - '0';
  18.  
  19.         return 0;
  20. }
  21.  
  22. void decodePassword( const char *pass, const char *key )
  23. {
  24.         unsigned int n1, n2;
  25.         typedef unsigned short ushort;
  26.         int password_index = 0;
  27.         unsigned char c;
  28.         //if(key.length() == 0)
  29.         //return pass;
  30.         for( n1 = 0, n2 = 0; n1 < strlen( pass ); n1 += 4 )
  31.         {
  32.                 ushort x = 0;
  33.  
  34.                 if(n1 + 4 > strlen( pass ) )
  35.                         break;
  36.  
  37.                 x += hexChar2int( pass[ n1 ] ) * 4096;
  38.                 x += hexChar2int( pass[ n1+1 ] ) * 256;
  39.                 x += hexChar2int( pass[ n1+2 ] ) * 16;
  40.                 x += hexChar2int( pass[ n1+3 ] );
  41.  
  42.                 c = ( unsigned char )( x ^ key[ n2++ ] );
  43.  
  44.                 password[ password_index++ ] = c;
  45.  
  46.                 if( n2 > strlen( key ) )
  47.                         n2 = 0;
  48.         }
  49.  
  50. }
  51.  
  52. int main( void )
  53. {
  54.         decodePassword( "Encrypted password from config.xml here", "user_name@jabber.org" );
  55.         printf( "Password:%s\n", password );
  56.  
  57.         return 0;
  58. }
  59. }
Add Comment
Please, Sign In to add comment