• lastlybutfirstly@lemmy.world
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    edit-2
    18 hours ago

    No, I mean the actual code. It’s been decades since I’ve used BASIC but a password programd would look vaguely like this:

    10 x=1234

    20 Print “What is the password?”

    30 If user input equals 1234 goto 60

    40 Print “Incorrect”

    50 Goto 20

    60 Print “Correct”

    • paris@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      1
      ·
      16 hours ago

      Your 1234 example is stored in plaintext, which is bad practice but still happens sometimes. Usually 1234 will be hashed (irreversible and functionally unique string) and the user input gets hashed with the same algorithm to check against the server’s stored hash.

      Passkeys are fundamentally different and work with public-private key pairs. It’s not possible for your public key to be “stored incorrectly” because it’s meant to be public. Your private key stays private and you never have to send it to the server to be checked against what they have stored. Instead, the server sends you a mathematical challenge that you solve with your private key. The resulting answer is also irreversible and functionally unique, but in such a way that the answer can be checked with the public key to make sure it was solved by the associated private key. It’s really clever math that’s worth watching or reading up on to understand.

      I don’t understand the maths well enough to give you a pseudocode example, but I always found trying to simplify it made it difficult to understand anyway. Every analogy ended up falling short because it was an analogy and not what was actually happening under the hood.