Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,14 @@
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.CRC32; use GNAT.CRC32;
with Interfaces; use Interfaces;
procedure TestCRC is
package IIO is new Ada.Text_IO.Modular_IO (Unsigned_32);
crc : CRC32;
num : Unsigned_32;
str : String := "The quick brown fox jumps over the lazy dog";
begin
Initialize (crc);
Update (crc, str);
num := Get_Value (crc);
IIO.Put (num, Base => 16); New_Line;
end TestCRC;

View file

@ -0,0 +1,37 @@
*> tectonics: cobc -xj crc32-zlib.cob -lz
identification division.
program-id. rosetta-crc32.
environment division.
configuration section.
repository.
function all intrinsic.
data division.
working-storage section.
01 crc32-initial usage binary-c-long.
01 crc32-result usage binary-c-long unsigned.
01 crc32-input.
05 value "The quick brown fox jumps over the lazy dog".
01 crc32-hex usage pointer.
procedure division.
crc32-main.
*> libz crc32
call "crc32" using
by value crc32-initial
by reference crc32-input
by value length(crc32-input)
returning crc32-result
on exception
display "error: no crc32 zlib linkage" upon syserr
end-call
call "printf" using "checksum: %lx" & x"0a" by value crc32-result
*> GnuCOBOL pointers are displayed in hex by default
set crc32-hex up by crc32-result
display 'crc32 of "' crc32-input '" is ' crc32-hex
goback.
end program rosetta-crc32.

View file

@ -0,0 +1,9 @@
using StringTools;
class Main {
static function main() {
var data = haxe.io.Bytes.ofString("The quick brown fox jumps over the lazy dog");
var crc = haxe.crypto.Crc32.make(data);
Sys.println(crc.hex());
}
}

View file

@ -0,0 +1,4 @@
sum: checksum "The quick brown fox jumps over the lazy dog" 'crc32
;== 1095738169
enbase sum 16 ;; available since 3.19.5
;== "414FA339"

View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
declare -i -a CRC32_LOOKUP_TABLE
__generate_crc_lookup_table() {
local -i -r LSB_CRC32_POLY=0xEDB88320 # The CRC32 polynomal LSB order
local -i index byte lsb
for index in {0..255}; do
((byte = 255 - index))
for _ in {0..7}; do # 8-bit lsb shift
((lsb = byte & 0x01, byte = ((byte >> 1) & 0x7FFFFFFF) ^ (lsb == 0 ? LSB_CRC32_POLY : 0)))
done
((CRC32_LOOKUP_TABLE[index] = byte))
done
}
__generate_crc_lookup_table
typeset -r CRC32_LOOKUP_TABLE
crc32_string() {
[[ ${#} -eq 1 ]] || return
local -i i byte crc=0xFFFFFFFF index
for ((i = 0; i < ${#1}; i++)); do
byte=$(printf '%d' "'${1:i:1}") # Get byte value of character at i
((index = (crc ^ byte) & 0xFF, crc = (CRC32_LOOKUP_TABLE[index] ^ (crc >> 8)) & 0xFFFFFFFF))
done
echo $((crc ^ 0xFFFFFFFF))
}
printf 'The CRC32 of: %s\nis: 0x%08x\n' "${1}" "$(crc32_string "${1}")"
# crc32_string "The quick brown fox jumps over the lazy dog"
# yields 414fa339

View file

@ -0,0 +1,52 @@
#!/usr/bin/env sh
# POSIX Shell CRC32 of string
# @Name: crc32.sh
# @Version: 1.0.1
# @Author: Léa Gris <lea.gris@noiraude.net>
# @Date: Wed, 27 Mar 2019
# @License: WTFPL http://www.wtfpl.net/
# POSIX Shell has no array or string index
# Implementing a pre-computed CRC32 byte indexed look-up table
# would cost more CPU cycles calling external tools like
# awk or tr to index records from a string.
# Computes the CRC32 of the input data stream
# <&1: The input data stream
# >&1: The CRC32 integer of the input data stream
crc32_stream() {
crc=0xFFFFFFFF # The Initial CRC32 value
p=0xedb88320 # The CRC32 polynomial
r=0 # The polynomial reminder
c='' # The current character
byte=0 # The byte value of the current character
# Iterates each character of the input stream
while c="$(dd bs=1 count=1 2>/dev/null)" && [ -n "$c" ]; do
byte=$(printf '%d' "'$c") # Converts the character into its byte value
r=$(((crc & 0xff) ^ byte)) # XOR LSB of CRC with current byte
# 8-bit lsb shift with XOR polynomial reminder when odd
for _ in _ _ _ _ _ _ _ _; do
t=$((r >> 1))
r=$(((r & 1) ? t ^ p : t))
done
crc=$(((crc >> 8) ^ r)) # XOR MSB of CRC with Reminder
done
# Output CRC32 integer XOR mask 32 bits
echo $((crc ^ 0xFFFFFFFF))
}
# Computes the CRC32 of the argument string
# 1: The argument string
# >&1: The CRC32 integer of the argument string
crc32_string() {
[ $# -eq 1 ] || return # argument required
# Streams with printf to prevent suffixing the string
# with a newline, since echo -n is not available in POSIX Shell
printf '%s' "$1" | crc32_stream
}
printf 'The CRC32 of: %s\nis: %08x\n' "$1" "$(crc32_string "$1")"
# crc32_string "The quick brown fox jumps over the lazy dog"
# yields 414fa339

View file

@ -0,0 +1,8 @@
String ← "The quick brown fox jumps over the lazy dog"
Key ← ⋕₁₆"1db710640"
InitCRC ← ⋕₁₆"ffffffff"
Xor ← °⋯⬚0≡≠∩⋯
ShR ← ⍜⋯(⬚0˜↻)⊃⋅∘∘
Table ← ≡⍥₈(ShR1 ⍥(Xor Key)⊸◿2)⇡256
⍢(Xor⊃(ShR8|˜⊡Table Xor◿256)⊙°⊂|>0⧻◌) InitCRC -@\0String
°⋕₁₆⍜⋯¬⊙◌

View file

@ -0,0 +1,32 @@
dim crctbl(255)
const crcc =&hEDB88320
sub gencrctable
for i= 0 to 255
k=i
for j=1 to 8
if k and 1 then
k=(k and &h7fffffff)\2 or (&h40000000 and ((k and &h80000000)<>0))
k=k xor crcc
else
k=(k and &h7fffffff)\2 or (&h40000000 and ((k and &h80000000)<>0))
end if
next ' j
crctbl(i)=k
next
end sub
function crc32 (buf)
dim r,r1,i
r=&hffffffff
for i=1 to len(buf)
r1=(r and &h7fffffff)\&h100 or (&h800000 and (r and &h80000000)<>0)
r=r1 xor crctbl((asc(mid(buf,i,1))xor r) and 255)
next
crc32=r xor &hffffffff
end function
'414FA339
gencrctable
wscript.stdout.writeline hex(crc32("The quick brown fox jumps over the lazy dog"))