/*
* ofpwgen: convert a string to an XOR'd
* hex string that can be used as the value
* for security-password in Open Firmware
*/
#include <stdio.h>

int
main(int argc, char **argv)
{
  int i = 0;
  /* XOR key used by Open Firmware */
  unsigned char key = 0xaa;
  
  if (argc != 2) {
    fprintf(stderr, "Usage: %s password\n", argv[0]);
    return 1;
  }
  
  /* print out the XOR'd version of pw in firmware format */
  while (argv[1][i] != 0) {
    printf("%%%.2x", ((unsigned char)(argv[1][i]))^key);
    i++;
  }
  printf("\n");
  
  return 0;
}

