#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>

/* program taking two lists of letters and
   making a key
   burt rosenberg, 29 aug 04
*/

#define NUM_LET 26

int cmpfc( const void * i, const void * j ) {
  int ii = * (int*) i ;
  int ij = * (int*) j ;
  return ii-ij ;
}

struct ae { int pLet; int cLet ; } ;

main( int argc, char * argv[] ) 
{
  struct ae a[NUM_LET] ;
  int i, j ;

  if ( argc<3 ) {
       printf("usage: %s plain-letter-list cipher-letter-list\n", argv[0] ) ;
       exit(0) ;
  }

  for (i=0;i<NUM_LET;i++) {
    a[i].pLet = tolower(argv[1][i]) ;
    a[i].cLet = tolower(argv[2][i]) ;
  }

  qsort( a, sizeof(a)/sizeof(a[0]), sizeof(a[0]), cmpfc ) ;

  for (i=0;i<NUM_LET;i++) {
    printf("%c", a[i].cLet) ;
  }
  printf("\n") ;
 
}
