Page 1 of 1

Password en SQLITE

Posted: Thu Jul 01, 2021 4:56 pm
by jorge.posadas
Grupo,

¿Alguien sabe CÓOMO poner un password en una base de datos SQLIT? es decir quiero que por programa ponerle un password y cuando se vaya a usar la base de datos, entonces quitarle el password para que la puedan usar.

Re: Password en SQLITE

Posted: Fri Jul 02, 2021 1:50 am
by Rathinagiri
Whether you want to encrypt the sqlite database with a password or you want to store the password in the database?

Re: Password en SQLITE

Posted: Fri Jul 02, 2021 4:39 am
by jorge.posadas
Rathinagiri

I want to store the password in the database And if you have an example of how to use it in PRG I would really appreciate it

Re: Password en SQLITE

Posted: Fri Jul 02, 2021 9:00 am
by Rathinagiri
If you want to store password in databases, there are so many hash functions available.

You can use hb_sha256( cPassword ) -> Hashed Text

Let me give you a small sample to save the password using HMGSQLITE library.

Code: Select all

IF AllTrim(pass.newpassword.value) == AllTrim(pass.confpassword.value)
   IF msgyesno("Are you sure to save this password?","Confirm Password Change")
      lOk := miscsql( oCtlDB, "update usermast u set u.userpw = " + c2sql( hb_sha256( AllTrim( pass.newpassword.value ) ) ) + " where u.usercode = "+ c2sql(cUserCode))
      if lOk
         msginfo("Password is changed successfully!")
         pass.release
      else
         msgstop( 'Database Error' )      
      endif   
   ENDIF
ENDIF