Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8247119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:44:11+00:00 2026-06-07T22:44:11+00:00

I’d like to offer the users ob my web-application the possibility to send out

  • 0

I’d like to offer the users ob my web-application the possibility to send out emails using our smtp-server.

The password for the user accounts are md5-hased and the smtp-server is hashing the received values to check for the right username-password kobination.

Now i’m looking for a good way to set up Zend_Mail_Transport_Smtp – I obviously need the plain-text password and forward it to the smtp-server which then converts it to a md5-hash.
But that means that i have to store the users password somewhere in plaintext, which i’d like to avoid.

Are there any best practices on how to set up an webmailer using the zend framework?

The only idea i had was to save the unhashed password in a session (the user accounts in my application are linked with the mail server accounts), but there has to be a better way to handle this situation

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:44:12+00:00Added an answer on June 7, 2026 at 10:44 pm

    What you can do is to store the password in a encoded format in the database and decode it in your application when you need it. Unfortunately MD5 is just a hashing function and you cannot decode to the plain password. I know three ways to accomplish this:

    1. Substitute letters:

      You can use something like ROT13 to replace letters in your plain password:

      // store this in the database
      $pw_rot = str_rot13( "plain_password" );
      // use this in the application
      $pw_plain = str_rot13( "cynva_cnffjbeq" );
      

      I wouldn’t recommend to use str_rot13() or something like this, because is easily guessed by someone who sees the password.

    2. Decode/encode without a key:

      Another way is to decode/encode the password with a function, which doesn’t need a key like Base64:

      // store this in the database
      $pw_base64 = base64_encode( "plain_password" );
      // use this in the application
      $pw_plain = base64_encode( "cGxhaW5fcGFzc3dvcmQ=" );
      

      A little bit better then the above, but I would use that only for testing purposes, because it’s easily implemented and to use.

    3. Decode/encode with a key:

      A better way is to use key and a symmetric block cipher like Blowfish:

      class Password {
        const KEY = 'your_secret_key_for_the_cipher';
      
        // encode the plain text with key for storing in the database
        public function encode( $plain_text ) {
          // set up the environment
          $td      = mcrypt_module_open( MCRYPT_BLOWFISH, '', MCRYPT_MODE_ECB, '' );
          $key     = substr( self::KEY, 0, mcrypt_enc_get_key_size( $td ) );
          $iv_size = mcrypt_enc_get_iv_size( $td );
          $iv      = mcrypt_create_iv( $iv_size, MCRYPT_RAND );
      
          if( mcrypt_generic_init( $td, $key, $iv ) != -1 ) {
            $cipher_text = mcrypt_generic( $td, $plain_text );
            // clean up the mcrypt enviroment
            mcrypt_generic_deinit( $td );
            mcrypt_module_close( $td );
          }
      
          // use hex value            
          return bin2hex( $cipher_text );
        }
      
        // decode the stored cipher text with key to use in the application
        public function decode( $cipher_text ) {
          // set up the environment
          $td      = mcrypt_module_open( MCRYPT_BLOWFISH, '', MCRYPT_MODE_ECB, '' );
          $key     = substr( self::KEY, 0, mcrypt_enc_get_key_size( $td ) );
          $iv_size = mcrypt_enc_get_iv_size( $td );
          $iv      = mcrypt_create_iv( $iv_size, MCRYPT_RAND );
      
          if( mcrypt_generic_init( $td, $key, $iv ) != -1 ) {
            $plain_text = mdecrypt_generic( $td, pack( "H*" , $cipher_text ) );
            // clean up the mcrypt environment
            mcrypt_generic_deinit( $td );
            mcrypt_module_close( $td );
          }
      
          // remove NUL which maybe added by padding the plain_text
          return rtrim( $plain_text, "\0" );
        }
      

      With this way only someone who has access to the database and the source code can decode the password. On the down side you have a more complex application and little bit performance impact. Also you can other symmetric block cipher.

    And the most important: Never store plain passwords.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.