In setup.go you aren't checking the errors from bcrypt.GenerateFromPassword 
or bcrypt.CompareHashAndPassword, do either of those return errors?

The documentation for sqlite3 says "The value is a text string, stored 
using the database encoding (UTF-8, UTF-16BE or UTF-16LE)", could it be 
your database is interpreting your UTF-8 encoded text into a UTF-16 string?

https://stackoverflow.com/questions/4532532/check-the-encoding-of-text-in-sqlite

Matt

On Tuesday, December 5, 2017 at 1:39:38 PM UTC-6, Gabriel Simmer wrote:
>
> Hey Gophers,
>
> I have a bit of a headscratcher for you guys today, hoping someone will be 
> able to help me track down where I've gone wrong. I have an SQLite3 
> database with user login info, including username, hashed password w/ 
> bcrypt, and so on. I also have a "setup" method that is triggered on the 
> first run of the application, which includes creating the database, setting 
> an admin password and fetching assets. There's one hitch - the hashed 
> password doesn't seem to be either:
>
>  - Stored properly
>  - Hashed properly
>  - Compared properly
>
> I've done some extensive testing and it appears bcrypt *is* hashing the 
> password, and I can compare it successfully right after, and before I put 
> it into the database. All good. However when I pull the hash from the 
> database later (on user login), bcrypt doesn't see the hash and the 
> password as equal and errors out. 
>
> Here is the GitHub repository's branch 
> <https://github.com/gmemstr/pogo/tree/setup>, if you want to fully test 
> the application, but the relevant files are setup.go 
> <https://github.com/gmemstr/pogo/blob/setup/setup.go#L38-L56> and 
> router/router.go 
> <https://github.com/gmemstr/pogo/blob/setup/router/router.go#L125-L207>. 
> I've left in some debugging checks, and will happily answer any questions I 
> haven't clarified. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to