funcion encriptar

funcion encriptar

Postby D.Fernandez » Sun Oct 27, 2024 3:49 am

Hola amigos tengo error en estas funciones de copilot para harbour y MSV

Code: Select all  Expand view  RUN
FUNCTION EncryptString( cInput, cKey )
    LOCAL cEncrypted := "", nKeyLen := LEN( cKey )
    LOCAL i, nChar

    FOR i := 1 TO LEN( cInput )
        nChar := ASC( SUBSTR( cInput, i, 1 ) ) $XOR$ ASC( SUBSTR( cKey, ( ( i - 1 ) % nKeyLen ) + 1, 1 ) )
        cEncrypted += CHR( nChar )
    NEXT

    RETURN cEncrypted



FUNCTION DecryptString( cEncrypted, cKey )
    RETURN EncryptString( cEncrypted, cKey )



STATIC FUNCTION XorChar( nChar1, nChar2 )
    RETURN BitXOr( nChar1, nChar2 )


tampoco funciona en Bcc77
Code: Select all  Expand view  RUN
cInput:= "dario5402()"
   cKey:= "askfdhndsc+64905483(^#)"
    FUNCTION EncryptString( cInput, cKey )
      LOCAL cEncrypted := "", nKeyLen := LEN( cKey )
      LOCAL i, nChar
 
      FOR i := 1 TO LEN( cInput )
          nChar := ASC( SUBSTR( cInput, i, 1 ) ) $XOR$ ASC( SUBSTR( cKey, ( ( i - 1 ) % nKeyLen ) + 1, 1 ) )
          cEncrypted += CHR( nChar )
      NEXT
 
      RETURN cEncrypted
 
 
 
  FUNCTION DecryptString( cEncrypted, cKey )
      RETURN EncryptString( cEncrypted, cKey )
 
 
 
  STATIC FUNCTION XorChar( nChar1, nChar2 )
RETURN BitXOr( nChar1, nChar2 )





Saludos y gracias
Dario Fernandez
Dario Fernandez
FWH 24.09, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 468
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay

Re: funcion encriptar

Postby Antonio Linares » Sun Oct 27, 2024 7:06 am

Estimado Dario,

[x]Harbour no admite $XOR$

Prueba a usar hb_bitXor() ó nXor() de FWH
regards, saludos

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

Re: funcion encriptar

Postby D.Fernandez » Sun Oct 27, 2024 7:23 am

Gracias Mestro.

Saludos.

Dario Fernandez
Dario Fernandez
FWH 24.09, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 468
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 69 guests