The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

fletcher

Fletcher’s checksum for R, in 16-, 32-, and 64-bit widths.

Fletcher’s checksum keeps two running sums as it walks the input and concatenates them into the result. It catches the reordering and single-bit errors a plain sum misses, at a fraction of the cost of a CRC. The algorithm lives in C; the R side is a thin wrapper.

Install

# install.packages("remotes")
remotes::install_github("chrislongros/fletcher")

Use

library(fletcher)

fletcher("abcde", 16)  # "c8f0"
fletcher("abcde", 32)  # "f04fc729"
fletcher("abcde", 64)  # "c8c6c527646362c6"

x can be a string, a raw vector, or a vector of byte values:

fletcher(charToRaw("abcde"), 32)          # "f04fc729"
fletcher(as.integer(charToRaw("abcde")))  # width defaults to 32

The result is a lowercase hex string of width / 4 characters.

Details

Input is read as little-endian words, so the output does not depend on the host’s byte order. A final partial word is zero-padded. The running sums start at zero and reduce modulo 2^(width/2) - 1; the checksum is the high sum shifted over the low sum.

License

MIT.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.