Results 1 to 3 of 3
  1. #1
    SomeAsianDude's Avatar
    Join Date
    Mar 2013
    Gender
    male
    Posts
    189
    Reputation
    10
    Thanks
    9

    Question Encrypt Passwords in MySQL to access and decrypt in GUI

    Hello! I was wondering if anyone could help me out?

    I'm trying to work on this particular component of my project for a class and not sure how to make it happen or if it is possible.

    What I want to do is:
    I have a database locally hosted using xampp. I created a table with 'Username' and 'Password' and my program the first part is a Login GUI it accesses the information to see if your login information is there and if it is, it logins and opens the next GUI. However, I don't know how to encrypt the passwords and then decrypt them on the program end. At this point, they're just plain text username and passwords.

    It isn't the most vital to my program that it encrypts passwords as this is for a class project and the user info is created by me before hand anyways but I think it'd be cool and would add to the complexity of the program and therefore my grade.

    I'm not an experienced Java coder.
    Any help would be appreciated !

  2. #2
    MikeRohsoft's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Los Santos
    Posts
    797
    Reputation
    593
    Thanks
    26,312
    Quote Originally Posted by SomeAsianDude View Post
    Hello! I was wondering if anyone could help me out?

    I'm trying to work on this particular component of my project for a class and not sure how to make it happen or if it is possible.

    What I want to do is:
    I have a database locally hosted using xampp. I created a table with 'Username' and 'Password' and my program the first part is a Login GUI it accesses the information to see if your login information is there and if it is, it logins and opens the next GUI. However, I don't know how to encrypt the passwords and then decrypt them on the program end. At this point, they're just plain text username and passwords.

    It isn't the most vital to my program that it encrypts passwords as this is for a class project and the user info is created by me before hand anyways but I think it'd be cool and would add to the complexity of the program and therefore my grade.

    I'm not an experienced Java coder.
    Any help would be appreciated !
    For ussual you dont do save it "encrypted", you better dont save the password
    what u should save is, a hash which makes sure the password is correct. (For example md5 base64 encoded string)
    To make it more difficult to reproduce it, you save it with "salt & pepper"
    for example you save also the timestamp when he set the password, (or his create date or whatever, you only must make sure you can access it any time)
    and some static string
    like
    Code:
    function getHash(string password, DWORD timestamp): string;
    begin
    	result := base64_encode(md5(password + toString(timestamp) + 'my Pepper String'));
    end;
    then u save the hash + timestamp to database, then on login, you fetch from database the timestamp + the hash, create the hash with the timestamp and the password the user have insert and compare it against your hash
    Last edited by MikeRohsoft; 11-13-2018 at 02:19 PM.

  3. #3
    Bababam's Avatar
    Join Date
    Nov 2020
    Gender
    female
    Posts
    6
    Reputation
    10
    Thanks
    1
    You typically do not encrypt or store passwords. You take the password from the user an hash it with another character as a salt. You store the hashed version and the salt. Then when they go to log in you rehash their Input with the same hashing algoritm and the same salt. The salt is typically unique for the user I�d.

    So

    Password
    Password + salt
    Hash(password + salt)
    Store: hash , salt

    Then
    Select * from id where user = user and hash = hash(password + salt)

Similar Threads

  1. [Unresolved] Encryption and Decryption, error
    By Ryan28 in forum C# Programming
    Replies: 3
    Last Post: 01-24-2017, 10:38 AM
  2. [Help Request] Forgot my Password on my old account and do not have access to that email.
    By Voidmetro123 in forum Account Recovery & Support
    Replies: 1
    Last Post: 08-11-2016, 03:12 PM
  3. [WTB] 00.07$ alts! 6$ full access and 1$ password changable alts!! skype zack_mpgh SALE!!!!
    By SPZACK_MPG in forum Minecraft Selling / Trading / Buying
    Replies: 0
    Last Post: 06-14-2014, 02:19 AM
  4. [WTS] Script Encrypting and Decrypting Service
    By ikillindreams in forum DayZ Selling / Trading / Buying
    Replies: 1
    Last Post: 02-01-2013, 11:18 PM
  5. [Source Code] Text Encrypter and Decrypter
    By rileyjstrickland in forum Visual Basic Programming
    Replies: 3
    Last Post: 11-09-2012, 08:32 PM