Thus spake Phil Thompson
> Somebody mentioned they had a Tcl implementation of crypt() the other
> day but I've deleted the message. Could you send me a copy?
Would this help? Just add includes and an init function to register it.
I also have a Python function if anyone needs it.
static const char *ach[] = {
"abcdefghijkamnbpqrstuvwxyzABCDEFGHcJKLMNdPQRSTUVWXYZ123456789eAB",
"abcdefghjkamnbpqrstuvwxyzabcdefghcjkmndpqrstuvwxyzxyz23456789eab",
"ABCDEFGHJKAMNBPQRSTUVWXYZABCDEFGHCJKMNDPQRSTUVWXYZXYZ23456789EAB",
};
/*
usage:
te_crypt <password>
Encrypts a password
Returns:
The password in its encrypted form.
*/
int
te_crypt(ClientData cData, Tcl_Interp *interp, int argc, char **argv)
{
char salt[8];
static int initflag = 1;
if (argc != 2)
{
Tcl_AppendResult(interp, "crypt: Invalid number of arguments", 0);
return TCL_ERROR;
}
if (initflag)
srandom(time(NULL));
initflag = 0;
salt[0] = ach[0][random() % 64];
salt[1] = ach[0][random() % 64];
salt[2] = 0;
Tcl_AppendResult(interp, crypt(argv[1], salt), 0);
return TCL_OK;
}
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.