big HASH +1 how ?

big HASH +1 how ?

Postby Jimmy » Wed Jun 21, 2023 3:18 am

hi,

guess i have a bit HASH (HEX) and want to add 1
Code: Select all  Expand view
6965129d6c68406c93fa74c7ef2696b6 +1 -> ?

how can i do it :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1584
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: big HASH +1 how ?

Postby Antonio Linares » Wed Jun 21, 2023 6:48 am

Dear Jimmy,

0x6965129d6c68406c93fa74c7ef2696b6 + 1
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: big HASH +1 how ?

Postby nageswaragunupudi » Wed Jun 21, 2023 7:46 am

Code: Select all  Expand view
  n := NUMTOHEX( 0x6965129d6c68406c93fa74c7ef2696b6 + 1 )
 

64-bit Exe only can handle this large value.
But 32 bit exe can not handle such large numbers
With 32-bit exe this is the result:
Code: Select all  Expand view
93FA74C7EF2696B7


For 32-bit exe, we can use this function with the same result:
Code: Select all  Expand view
function HexAddOne( cStr )

   HB_INLINE( cStr ) {
      char * text = ( char * ) hb_parc( 1 );
      int iPos = hb_parclen( 1 );
      char c   = '0';

      while ( iPos > 0 && c == '0' )
      {
         c  = text[ --iPos ];
         c  = ( ( c == 'f' || c == 'F' ) ? '0' : ( c == '9' ? 'a' : c + 1 ) );
         text[ iPos ] = c;
      }
      hb_ret();
   }

return cStr


Using this function
Code: Select all  Expand view
? c := hexaddone( "6965129d6c68406c93fa74c7ef2696b6" ) // --> 6965129d6c68406c93fa74c7ef2696b7

This function works without any limit on the size. Even hex strings larger than 32 bytes.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Otto and 64 guests