#include "mbconfig.h"
#include "myassert.h"
#include <stdlib.h>
#include <string.h>
#include "crypt.h"
Go to the source code of this file.
|  | 
| char * | mbdyn_make_salt (char *salt, size_t saltlen, const char *salt_format) | 
|  | 
      
        
          | char* mbdyn_make_salt | ( | char * | salt, | 
        
          |  |  | size_t | saltlen, | 
        
          |  |  | const char * | salt_format | 
        
          |  | ) |  |  | 
      
 
Definition at line 40 of file crypt.cc.
References ASSERT, buf, and STRLENOF.
Referenced by main().
   42         static char salt_charset[] =
 
   43                 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
 
   45         ASSERT(strlen(salt_charset) == 64);
 
   51 #if defined(HAVE_DEV_RANDOM) || defined(HAVE_DEV_URANDOM) 
   54 #if defined(HAVE_DEV_RANDOM) 
   55         fin = fopen(
"/dev/random");
 
   56 #elif defined(HAVE_DEV_URANDOM) 
   57         fin = fopen(
"/dev/urandom");
 
   64         for (
unsigned int i = 0; i < 
STRLENOF(buf); i++) {
 
   65                 buf[i] = salt_charset[buf[i] % 
STRLENOF(salt_charset)];
 
   68         for (
unsigned int i = 0; i < 
STRLENOF(buf); i++) {
 
   69                 buf[i] = salt_charset[rand() % 
STRLENOF(salt_charset)];
 
   74                 snprintf(salt, saltlen, salt_format, buf);
 
   76                 strncpy(salt, buf, saltlen);
 
#define ASSERT(expression)
static doublereal buf[BUFSIZE]