root/trunk/freewrt/tools/md5crypt/main.c
| Revision 3125, 1.6 kB (checked in by tg, 5 years ago) |
|---|
| Line | |
|---|---|
| 1 | /*- |
| 2 | * Copyright (c) 2007 |
| 3 | * Thorsten Glaser <tg@mirbsd.de> |
| 4 | * |
| 5 | * Provided that these terms and disclaimer and all copyright notices |
| 6 | * are retained or reproduced in an accompanying document, permission |
| 7 | * is granted to deal in this work without restriction, including un- |
| 8 | * limited rights to use, publicly perform, distribute, sell, modify, |
| 9 | * merge, give away, or sublicence. |
| 10 | * |
| 11 | * Advertising materials mentioning features or use of this work must |
| 12 | * display the following acknowledgement: |
| 13 | * This product includes material provided by Thorsten Glaser. |
| 14 | * This product includes software developed by Niels Provos. |
| 15 | * |
| 16 | * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to |
| 17 | * the utmost extent permitted by applicable law, neither express nor |
| 18 | * implied; without malicious intent or gross negligence. In no event |
| 19 | * may a licensor, author or contributor be held liable for indirect, |
| 20 | * direct, other damage, loss, or other issues arising in any way out |
| 21 | * of dealing in the work, even if advised of the possibility of such |
| 22 | * damage or existence of a defect, except proven that it results out |
| 23 | * of said person's immediate fault when using the work as intended. |
| 24 | */ |
| 25 | |
| 26 | #include <stdio.h> |
| 27 | #include <stdlib.h> |
| 28 | #include <string.h> |
| 29 | #include <unistd.h> |
| 30 | #include "md5crypt.h" |
| 31 | |
| 32 | int |
| 33 | main(int argc, char *argv[]) |
| 34 | { |
| 35 | char salt[16]; |
| 36 | char *pw; |
| 37 | |
| 38 | if (!argv[1]) { |
| 39 | fprintf(stderr, "Syntax Error!\n"); |
| 40 | return (1); |
| 41 | } |
| 42 | if (!pwd_gensalt(salt, sizeof (salt))) |
| 43 | return (255); |
| 44 | if ((pw = md5crypt(argv[1], salt)) == NULL) { |
| 45 | fprintf(stderr, "Error generating password!\n"); |
| 46 | return (1); |
| 47 | } |
| 48 | printf("%s\n", pw); |
| 49 | return (0); |
| 50 | } |
Note: See TracBrowser for help on using the browser.


