Sektion Angewandte Informationsverarbeitung

Übungen zu Systemnahe Software I, Wintersemester 1996/97

Blatt 3

Beispiellösung zu Aufgabe 4 (5 Punkte)

#include <stdio.h>

#define LENGTH 3

int main( void ){
  char crypt[ LENGTH ], c;
  int index = 0;

  while( (c = getchar()) != EOF ){
    crypt[ index ] = c;
    index++;
    if( index >= LENGTH ){
      while( index > 0 ){
        index--;
        putchar( crypt[ index ] );
      }
    }
  }
  while( index > 0 ){
    index--;
    putchar( crypt[ index ] );
  }

  return 0;
}

/*
turing$ make
gcc -Wall crypta.c -o crypta 
turing$ echo "Geheimer Text :-)" | crypta 
heGmie rexeT: t
)-turing$ 
turing$ echo "Geheimer Text :-)" | crypta | crypta 
Geheimer Text :-)
*/

Beispiellösung zu Aufgabe 5 (5 Punkte)

#include <stdio.h>

#define KEY 0x1f

int main( void ){
  char c;

  while( (c = getchar()) != EOF ){
    putchar( c ^ KEY );
  }

  return 0;
}

/*
turing$ make cryptb
gcc -Wall cryptb.c -o cryptb 
turing$ echo "Geheimer Text :-)" | cryptb
Xzwzvrzm?Kzgk?%26turing$ 
turing$ echo "Geheimer Text :-)" | cryptb | cryptb
Geheimer Text :-)
turing$ 
*/