randpassphrase

/*
   randpassphrase.c
   This makes use of /dev/random
   Copyright 2006 Hal Canary
   DTPD (Dedicated to the Public Domain)
   cc -o randpassphrase randpassphrase.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
  FILE *devrandom;
  char source [] = "/dev/random";
  unsigned int num;
  if ((devrandom = fopen(source, "rb")) == NULL) {
    fprintf(stderr, "Cannot open %s\n", source);
    exit(EXIT_FAILURE);
  }
  int i;
  for (i=0; i< 28; i++) {
    if (fread(&num, sizeof(num), 1, devrandom) != 1) {
      fprintf(stderr, "%s: file read error.\n", source);
      exit(EXIT_FAILURE);
    }
    printf("%c",((num % 26) + 97));
    fflush(stdout);
    if (i%4 == 3) { printf(" "); }
  }
  close(devrandom);
  printf("\n");
  return(0);
}