Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Acerca del sys(2007) -suma de verificación-
Message
 
 
À
03/07/2002 17:44:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00675146
Message ID:
00675196
Vues:
8
>Hola, alguien conoce el algoritmo que genera el checksum de una cadena, utilizando el SYS(2007) de VFP, o en su defecto alguna otra rutina que genere un checksum aunque no sea el mismo de VFP.

Hola, Pablo.

Te paso esta que tenía por ahí. Es del tiempo del arquero, pero en la época que la escribí usaba y funcionaba bien. No es nada académica, sino un invento casero.

Espero que te sirva:
* Function...: wBcc
* Author.....: MARTIN
* Date.......: 12/12/1996
* Notes......: Generates a BCC code from a string (Ver 2.0 - ASCII between 32~127)
* Parameters.: tcString
* Returns....: a one byte BCC code
* See Also...: wCRIPT
* 
lparameter tcString

local lnAcum, lnBase, q, lnAsc

* Initialize acummulator
*
lnAcum = 7

* Generates a Base from the first and last characters of the string
*
lnBase = ( asc( left(tcString, 1) ) - asc( right(tcString, 1) ) ) * 4.6

for q = len(tcString) to 1 step -1              && Scans the string Backward
	
	lnAsc = asc( substr(tcString, q, 1) )  && Each character in the string
	
	if mod( q, 2) = mod( lnAsc, 2)         && Sometimes, complements to 200
		lnAsc = 200 - lnAsc
	endif
	
	lnAsc = abs( lnAsc + lnBase + q/1.7 )  && Crunch the ascii value
	
	lnAcum = lnAcum + lnAsc                && Accumulates the crunched value
next

do while !between( lnAcum, 32, 127 )
	if lnAcum < 32
		lnAcum = mod( int( lnAcum * len(tcString) )+ lnBase, 77 )
	else
		lnAcum = mod( int( lnAcum / len(tcString) )- lnBase, 77 )
	endif
	lnBase = lnBase + 2
enddo

return chr( lnAcum )
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform