Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Derek Slager's BCrypt Class for C# Check Password Method failed

Derek Slager's BCrypt Class for C# Check Password Method failed

Scheduled Pinned Locked Moved C#
csharpquestiondatabasemysqlvisual-studio
20 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Garth J Lancaster

    There appears to be a more up-to-date version here http://bcrypt.codeplex.com/[^] Nonetheless, I did a quick and dirty test with that version you used with VS2005 :-

    namespace DSBcryptTest
    {
    class Program
    {
    static void Main(string[] args)
    {
    String Password_Text = "Lorem_ipsum_dolor_sit_amet";

            String Password\_Hashed = BCrypt.HashPassword(Password\_Text, BCrypt.GenerateSalt(12));
            Console.WriteLine("Hashed Password {0}", Password\_Hashed);
    
            String Test\_Password\_Text = Password\_Text;
    
            if (BCrypt.CheckPassword(Test\_Password\_Text, Password\_Hashed))
            {
                Console.WriteLine("Passwords Match");
            }
    
        }
    }
    

    and there was nothing wrong / I got the expected result - obviously I should be using Nunit/unit tests etc, but meh ... I copied BCrypt.cs into a new project, removed the assembly directive at the top, then used it directly as opposed to the dll version - but that wouldn't matter - it just means I can step into the code So, Im sorry, I cant think of where to go

    A Offline
    A Offline
    ahmed_one
    wrote on last edited by
    #11

    Thanks for reply.

    Garth J Lancaster wrote:

    I copied BCrypt.cs into a new project, removed the assembly directive at the top, then used it directly as opposed to the dll version - but that wouldn't matter - it just means I can step into the code

    I didn't get the above part "removed the assembly directive"?? what does it mean? I am also using BCrypt.cs file not the dll.. May be assembly directive has something to do with my problem?

    G 2 Replies Last reply
    0
    • A ahmed_one

      Thanks for reply.

      Garth J Lancaster wrote:

      I copied BCrypt.cs into a new project, removed the assembly directive at the top, then used it directly as opposed to the dll version - but that wouldn't matter - it just means I can step into the code

      I didn't get the above part "removed the assembly directive"?? what does it mean? I am also using BCrypt.cs file not the dll.. May be assembly directive has something to do with my problem?

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #12

      nup, not the issue - you wouldn't even be able to build it if that were the issue - I had a 'Duplicate AssemblyVersion Attribute' error with the same in AssemblyInfo.cs - so I removed [assembly: System.Reflection.AssemblyVersion("0.1")] from near the top of my copy of BCrypt.cs All I proved was there's nothing obviously wrong with that version of BCrypt.cs, but it was only one test

      A 1 Reply Last reply
      0
      • A ahmed_one

        Thanks for reply.

        Garth J Lancaster wrote:

        I copied BCrypt.cs into a new project, removed the assembly directive at the top, then used it directly as opposed to the dll version - but that wouldn't matter - it just means I can step into the code

        I didn't get the above part "removed the assembly directive"?? what does it mean? I am also using BCrypt.cs file not the dll.. May be assembly directive has something to do with my problem?

        G Offline
        G Offline
        Garth J Lancaster
        wrote on last edited by
        #13

        btw - what is the length of the hashed password you get back from the DB ?

        A 2 Replies Last reply
        0
        • G Garth J Lancaster

          nup, not the issue - you wouldn't even be able to build it if that were the issue - I had a 'Duplicate AssemblyVersion Attribute' error with the same in AssemblyInfo.cs - so I removed [assembly: System.Reflection.AssemblyVersion("0.1")] from near the top of my copy of BCrypt.cs All I proved was there's nothing obviously wrong with that version of BCrypt.cs, but it was only one test

          A Offline
          A Offline
          ahmed_one
          wrote on last edited by
          #14

          Ok so may be I need to also test it with simple code, after the successful test I will add it to my project. I will let you know the result of test. Thanks

          1 Reply Last reply
          0
          • G Garth J Lancaster

            btw - what is the length of the hashed password you get back from the DB ?

            A Offline
            A Offline
            ahmed_one
            wrote on last edited by
            #15

            BCrypt hashed password is returning 60 Char length in my case.

            1 Reply Last reply
            0
            • G Garth J Lancaster

              btw - what is the length of the hashed password you get back from the DB ?

              A Offline
              A Offline
              ahmed_one
              wrote on last edited by
              #16

              I don't believe it...I've done hours and hours of testing and all of them is succeed...And guess what is the stupid mistake I was doing?? I've accidentally set CharacterCasing to upper when creating new user...And in Login Form it is set to default normal. Now it is working... Thanks for be patient with my stupidity. Ahmed

              P G 2 Replies Last reply
              0
              • A ahmed_one

                I don't believe it...I've done hours and hours of testing and all of them is succeed...And guess what is the stupid mistake I was doing?? I've accidentally set CharacterCasing to upper when creating new user...And in Login Form it is set to default normal. Now it is working... Thanks for be patient with my stupidity. Ahmed

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #17

                Well done for fixing it. Don't be worried about it - we've all made mistakes like this at one time or another.

                A 1 Reply Last reply
                0
                • P Pete OHanlon

                  Well done for fixing it. Don't be worried about it - we've all made mistakes like this at one time or another.

                  A Offline
                  A Offline
                  ahmed_one
                  wrote on last edited by
                  #18

                  Thanks....as a beginner these mistakes surely hard to find, but no doubt they make me learn something.....

                  1 Reply Last reply
                  0
                  • A ahmed_one

                    I don't believe it...I've done hours and hours of testing and all of them is succeed...And guess what is the stupid mistake I was doing?? I've accidentally set CharacterCasing to upper when creating new user...And in Login Form it is set to default normal. Now it is working... Thanks for be patient with my stupidity. Ahmed

                    G Offline
                    G Offline
                    Garth J Lancaster
                    wrote on last edited by
                    #19

                    as POH said 'well done' - you got there in the end 'next time', when using someone else's code, knock up a set of unit tests and make sure its working before you start coding against it in anger - that will eliminate it from the things you have to consider when it all looks pear-shaped 'g'

                    A 1 Reply Last reply
                    0
                    • G Garth J Lancaster

                      as POH said 'well done' - you got there in the end 'next time', when using someone else's code, knock up a set of unit tests and make sure its working before you start coding against it in anger - that will eliminate it from the things you have to consider when it all looks pear-shaped 'g'

                      A Offline
                      A Offline
                      ahmed_one
                      wrote on last edited by
                      #20

                      Thanks...I will follow your guidelines..

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups