| |
|
|
p.specht
| "Fletcher's Checksum" (likewise How z.B. Adlers Checksum) forms a positionsabhängige Checksumme - integrally in the senses of/ one undertow. CRC ("Zyklische Redundanz")-amount, though with plenty less Rechenaufwand. The nachstehende Algorithmus watts of John G. Fletcher into 1970it-years on the Lawrence Livermore Institute develops - for Atombombentests ...
proc FletcherChecksum :parameters DataMsg$
' without each Gewähr, insb. can rights Third consist!
var Length_of_Data&=len(DataMsg$)
declare c1&,c2&,c3&, i& ,s1&,s2&,s3&,s4&
whileloop Length_Of_Data&
c1&=c1&+ord(Mid$(DataMsg$,&loop,1))
c1&=c1& & $00ff :c2&=c2&+c1&:c2&=c2& & $00ff
EndWhile :c3&=c2&:c2&=c2&>>4 :c2&=c2& & $0f
if c2&>=$0A :s1&=c2&+ $37 :else :s1&=c2&+$30
endif:c2&=c3& & $0f
if c2&>= $0a:s2&=c2&+ $37 :else :s2&=c2&+ $30
endif:c3&=c1&:c1&=c1&>>4 :c1&=c1& & $0f
if c1&>= $0a :s3&=c1&+ $37 :else :s3&=c1&+ $30
endif :c1&=c3& & $0f
if c1&>=$0a:s4&=c1&+ $37 :else :s4&=c1&+ $30
endif:return chr $(s1&)+chr $(s2&)+chr $(s3&)+chr $(s4&)
endproc
CLS
Selbsttest:
case FletcherChecksum("5522 18 1137 00 003")<>"1C76":print "Error 1"
case FletcherChecksum("5522 18 3137 00 003")<>"3278":print "Error 2"
case FletcherChecksum("5522 18 1130 00 002")<>"E36E":print "Error 3"
case FletcherChecksum("5522 18 1401 00 001")<>"ED6E":print "Error 4"
case FletcherChecksum("5522 18 1302 00 003")<>"ED70":print "Error 5"
case FletcherChecksum("5522 18 1302 00 004")<>"EE71":print "Error 6"
case FletcherChecksum("5522 18 1302 00 009")<>"F376":print "Error 7"
case FletcherChecksum("5522 18 3147 00 009")<>"417F":print "Error 8"
case FletcherChecksum("5522 18 1137 00 004")<>"1D77":print "Error 9"
case FletcherChecksum("5522 18 3137 00 009")<>"3379":print "Error 10"
case FletcherChecksum("5522 18 1602 00 000")<>"0870":print "Error 11"
print "\n Fletchertest 10 yields korrekterweise";
print " ";FletcherChecksum("5522 18 3137 00 009");" instead of '3379'."
print " it could itself circa a Eingabefehler with whom Testwerten deal!"
beep: print "\n Fletcher-Test done.\n"
waitinput:END
|
|
|
| XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 05/19/21 ▲ |
|
|
|