FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour big HASH +1 how ?
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
big HASH +1 how ?
Posted: Wed Jun 21, 2023 03:18 AM
hi,

guess i have a bit HASH (HEX) and want to add 1
Code (fw): Select all Collapse
6965129d6c68406c93fa74c7ef2696b6 +1 -> ?
how can i do it :?:
greeting,

Jimmy
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: big HASH +1 how ?
Posted: Wed Jun 21, 2023 06:48 AM

Dear Jimmy,

0x6965129d6c68406c93fa74c7ef2696b6 + 1

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: big HASH +1 how ?
Posted: Wed Jun 21, 2023 07:46 AM
Code (fw): Select all Collapse
   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 (fw): Select all Collapse
93FA74C7EF2696B7
For 32-bit exe, we can use this function with the same result:
Code (fw): Select all Collapse
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 (fw): Select all Collapse
? 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

Continue the discussion