(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



"makekey" for Linux


2008/12/25

By Steggy
BCS Technology Limited
Email: steggy@bcstechnology.net
Web Site: http://www.bcstechnology.net

The need for makekey has to do with interfacing to a Throughbred Dictionary-IV app originally written to run on SCO OSR5. I now have complete portability for any other use of the app.

Apparently there was once a Linux makekey, but it was "deprecated" in favor of "crypt(3)".

Apparently there was also (and may still be somewhere) a command line "crypt" that I could have "front-ended" for my needs, but it doesn't exist on my system. As there really isn't much to this, I just went ahead and wrote what I needed.

Compile source with gcc -lcrypt -m32 -o makekey makekey.c. The -m32 option is required on a 64 bit system. Operation is the same as makekey found on SCO, BSD, AIX, etc.



makekey: Generate Encrypted Password

Copyright (C)1994-2009 by BCS Technology Limited. All rights reserved.

Permission is granted to use, copy, modify and/or distribute this soft- ware, provided proper attribution and credit is given and all copyright notices remain intact. This software is *NOT* in the public domain and has *NOT* been GPLed.

DISCLAIMER: BCS Technology Limited does not warrant that this software
is suitable for any particular purpose, or that it will
even work as intended. No technical support of any kind
will be offered. We take no responsibility for anything
unpleasant that might happen to your system, your business
or your financial well-being due to the use of this soft-
ware. In other words, USE AT YOUR OWN RISK.


/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *                                                                         * *
* *                   makekey: Generate Encrypted Password                  * *
* *                                                                         * *
* * Copyright (C)1994-2009 by BCS Technology Limited.  All rights reserved. * *
* *                                                                         * *
* * Permission is granted to use, copy, modify and/or distribute this soft- * *
* * ware, provided proper attribution and credit is given and all copyright * *
* * notices remain intact.  This software is *NOT* in the public domain and * *
* * has *NOT* been GPLed.                                                   * *
* *                                                                         * *
* * DISCLAIMER:  BCS Technology Limited does not warrant that this software * *
* *              is suitable for any particular purpose,  or that  it  will * *
* *              even work as intended.  No technical support of  any  kind * *
* *              will be offered.  We take no responsibility  for  anything * *
* *              unpleasant that might happen to your system, your business * *
* *              or your financial well-being due to the use of this  soft- * *
* *              ware.  In other words, USE AT YOUR OWN RISK.               * *
* *                                                                         * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                                             *
* makekey reads from STDIN & writes to STDOUT.  Input should consist of an 8  *
* character password string followed by a 2 character salt.  The salt charac- *
* ters should be taken from the letters a-z & A-Z, numerals, . & /.  The salt *
* is returned at the beginning of the encrypted output string.  Results are   *
* undefined if the input string is not 10 characters in total length.  Excess *
* input will be silently discarded.                                           *
*                                                                             *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

// To compile on most Linux distros:

//	gcc -o makekey -m32 -lcrypt makekey.c

/*===========================================================================*/

/* global declarations */

#define	INPBUFSIZ	10			// input buffer size
#define	KEYSIZ		8			// input key size
#define	SALTSIZ		2			// input salt size

char	NUL='\0';				// null string terminator

void	collect(char *);			// collect input

/*===========================================================================*/

/* makekey: generate encrypted password */

int main(void) {

    char	*ec;				// encrypted string pointer
    char	inpbuf[INPBUFSIZ+1];		// input buffer
    char	key[KEYSIZ+1];			// key
    char	salt[SALTSIZ+1];		// salt
    int		eclen;				// encrypted string length

    collect(inpbuf);				// collect input
    strncpy(key,inpbuf,KEYSIZ);			// extract key
    strncpy(salt,inpbuf+KEYSIZ,SALTSIZ);	// extract salt
    key[KEYSIZ]=NUL;				// terminate key
    salt[SALTSIZ]=NUL;				// terminate salt
    eclen=(strlen(ec=crypt(key,salt)));		// encrypt
    if (write(STDOUT_FILENO,ec,eclen)!=eclen)
	perror("stdout");			// output <> input
    exit(0);					// done
}
/*===========================================================================*/

/* collect input string, at most INPBUFSIZ chars */

void collect(char *buf) {

    int		c,ct=0;

    while ((c=getchar()) != EOF) {
	if (ct<INPBUFSIZ) {
	    *(buf++)=c;
	    ct++;
	}
    }
    *(buf)=NUL;					// terminate input string
}
/*===========================================================================*/

/* copyright declaration for `what' command */

    const char *what[]={
	"@(#)makekey: BCS Technology Limited Password Encrypter",
	"@(#)",
	"@(#)Copyright (C)1994-2009 by BCS Technology Limited.  All rights",
	"@(#)reserved.  Permission granted to  use,  copy,  modify  and/or",
	"@(#)distribute this software,  providing  proper  attribution  is",
	"@(#)given and copyright notices remain intact.   This software is",
	"@(#)*NOT* in the public domain and has *NOT* been GPLed.",
	"@(#)",
	"@(#)BCS Technology Limited DOES NOT accept any responsibility for",
	"@(#)anything bad that might occur as a consequence  of  using  or",
	"@(#)modifying this software.  USE AT YOUR OWN RISK."
    };
/*===========================================================================*/




More Articles by Steggy




Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar


Auto FTP Manager


/BDD/makekey.html copyright December 2008 Steggy All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


book graphic unix and linux troubleshooting guide

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!



 I sell and support
 Kerio Mail server






More:
       - Linux
       - OSR5
       - Code
       - Unix
       - Steggy


Unix/Linux Consultants

Skills Tests

Guest Post Here