Ignore:
Timestamp:
Mar 17, 2009, 9:50:20 PM (13 years ago)
Author:
livings124
Message:

#1276 encrypt the password to access web client interface using SHA-2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/crypto.c

    r7870 r8072  
    2020
    2121#include <openssl/bn.h>
     22#include <openssl/des.h>
    2223#include <openssl/dh.h>
    2324#include <openssl/err.h>
     
    350351}
    351352
     353/***
     354****
     355***/
     356
     357char*
     358tr_crypt( const void * plaintext )
     359{
     360    static const char * salter = "0123456789"
     361                                 "abcdefghijklmnopqrstuvwxyz"
     362                                 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     363                                 "./";
     364    static const size_t salter_len = 64;
     365
     366    int i;
     367    char salt[12];
     368
     369    memcpy( salt, "$1$", 3 );
     370    for( i=0; i<8; ++i )
     371        salt[3+i] = salter[ tr_cryptoRandInt( salter_len ) ];
     372    salt[11] = '\0';
     373
     374    return tr_strdup( DES_crypt( plaintext, salt ) );
     375}
Note: See TracChangeset for help on using the changeset viewer.