Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2011
    Location
    india- new delhi
    Posts
    31

    Unanswered: How to save string (username password) in encrypted form in Mysql database,

    Good morning all,
    I am using c++ and also using wxWidget, In backend i m using MySql C API, i want to save user name and password in encrypted form inside the database,
    when user will try to login,I will decrypt the data for authentication,
    1-Is there any headerfiles in c++ who can handle encryption or decryption?
    2-is there any functions in mysql who can save the data in encrypt form and decrypt the data when required?
    Amit Pathak
    S/w Developer
    Zero Systems Pvt Ltd..

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Hi,

    this is certainly one way of achieving a login solution. However, a more robust solution is store the encrypted password in the database and compare the encrypted password from your application with that in the database.

    MySQL provides MD5() function which encrypts a string. MD5 is a one way hashing algorithm i.e. once hashed you can never get back your original string. If the password being passed in is also encrypted with MD5 and you compare the same string in the database with your passed in string. If they match you have a login.

    It just means that when someone forgets their password you have to assign a new password for them, you cannot read their password from the database.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Reading up about MD5, as technology advances using brute force methods on every string will take less and less time, but for the majority of cases this is sufficient. Failing that there is another function called SHA and SHA2. MySQL 5.1 offers a full range of security functions:

    MySQL :: MySQL 5.1 Reference Manual :: 11.13 Encryption and Compression Functions
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •