English
Source / code snippets

Checksummenbildung vereinfacht: Fletcher-Algorithmus

 

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 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/19/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.453 Views

Untitledvor 0 min.
Rschnett08/06/22
p.specht11/21/21
R.Schneider11/20/21
Uwe Lang11/20/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie