Plugin Directory

Changeset 543280


Ignore:
Timestamp:
05/12/2012 11:25:51 AM (13 years ago)
Author:
hel.io
Message:

Implemented encryption for passwords

File:
1 edited

Legend:

Unmodified
Added
Removed
  • smtp/trunk/smtp.php

    r402025 r543280  
    22/*
    33Plugin Name: SMTP
    4 Version: 1.0
    5 Plugin URI: http://hel.io/wordpress/smtp
     4Version: 1.1
     5Plugin URI: http://hel.io/wordpress/smtp/
    66Description: Allows you to configure and use a SMTP server (such as Gmail) for sending emails.
    77Author: Sorin Iclanzan
    88Author URI: http://hel.io/
    99*/
     10
     11// Key used for encrypting and decrypting passwords
     12define( CRYPT_KEY, '-J5:2Yqd?Ri9wLjN' );
    1013
    1114// This is run when you activate the plugin, adding the default options to the database
     
    149152function smtp_password() {
    150153    $options = get_option('smtp_options');
    151     echo "<input id='password' name='smtp_options[password]' type='text' class='regular-text' value='{$options['password']}' />";
     154    echo "<input id='password' name='smtp_options[password]' type='password' value='' " . $options['password'] ? "placeholder='&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;'" : "" . " />";
    152155}
    153156
     
    173176    if ($input['password'] == '')
    174177        $input['password'] = $smtp_options['password'];
     178    else
     179        $input['password'] = encrypt_string( $input['password'], CRYPT_KEY );
    175180   
    176181    return $input;
     182}
     183
     184/*
     185 * Encrypt $string using $key
     186 */
     187function encrypt_string( $string, $key ) {
     188    return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));
     189}
     190
     191/*
     192 * Decrypt $string using $key
     193 */
     194function decrypt_string( $string, $key ) {
     195    return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
    177196}
    178197
     
    206225        $phpmailer->SMTPAuth = true;
    207226        $phpmailer->Username = $smtp_options['username'];
    208         $phpmailer->Password = $smtp_options['password'];
     227        $phpmailer->Password = decrypt_string( $smtp_options['password'], CRYPT_KEY );
    209228    }
    210229}
Note: See TracChangeset for help on using the changeset viewer.