Deze cursus is gearchiveerd · Deze cursus is nu afgesloten. Je kunt je niet meer registreren of nieuwe oplossingen indienen, maar je eerdere werk en resultaten blijven beschikbaar.
Opgepast! Het lijkt erop dat je Dodona gebruikt binnen een andere webpagina waardoor mogelijk niet alles goed werkt. Laat dit weten aan de lesgever zodat die het probleem kan oplossen door een instelling in de leeromgeving aan te passen. Ondertussen kan je op deze link klikken om Dodona te openen in een nieuw venster.
Opgepast! De pagina kon niet volledig ingeladen worden, waarschijnlijk door een netwerkprobleem. Het kan zijn dat niet alle functionaliteit beschikbaar is. Probeer de pagina te verversen.
- examen (groep 2)
- Mens vs Excel: 0 - 1
- A fish called ASCII
- COVID-19
- Steganografie
Log in om je oplossingen te testen.
decToChar () {
# converts single-byte decimal value to equivalent character
# arg: decimal number from 0-255
# out: one character
echo -n -e "\x$(printf %02X "$1")"
}
readDecimal() {
# Read the n'th decimal from a file. This function looks at the 2 least significant bits of 4 consecutive bytes in
# the given file and pastes them together to decode the decimal.
# arg1: decimal offset
# arg2: filename from which the given decimal should be read and decoded.
readcharDec () {
# read one character from file & convert to equivalent decimal value
# arg1: offset (# of bytes to skip before reading)
# arg2: filename
# out: decimal value from 0-255
VAL=$(xxd -p -l1 -s $1 $2)
printf %d "0x$VAL"
}
readLSB2 () {
# read the 2 LSB's from the byte at the given position in the given file.
# arg1: byte offset
# arg2: filename
READ_BYTE=$(readcharDec $1 $2)
echo $(( READ_BYTE & 3 ))
}
CURRENT_DECIMAL=0
IDX=$1
FILE=$2
for ((j = 3; j > 0; j--)); do
CURRENT_VAL=$(readLSB2 $(( IDX * 4 + j )) $FILE)
CURRENT_DECIMAL=$(( (CURRENT_DECIMAL | CURRENT_VAL) << 2 ))
done
CURRENT_VAL=$(readLSB2 $(( IDX * 4 )) $FILE)
CURRENT_DECIMAL=$(( (CURRENT_DECIMAL | CURRENT_VAL) ))
echo "$CURRENT_DECIMAL"
}