Module · Detail

Simple Password Hash & Mini-Login

This module conveys basic principles of password processing through hash functions. It shows how comparison logic and character processing are used to implement a simple login mechanism.

Time 35 minutes
The building block introduces the fundamental principle of hash functions and their application in authentication systems. It develops a simplified process that converts the characters of a password into numerical values and combines them into a hash value. Learners structure the processing using loops and conditions, making clear decisions about handling different character types. In the second step, this model is applied to a login scenario where only hash values are compared, not the plaintext. The connection between abstract security concepts and concrete implementation is central. Compact
Language Python 3
Tasks 2
Preview image: Simple Password Hash & Mini-Login

Introduction (Original excerpt)

In real systems, a password is ideally not stored as plaintext. Instead, a hash is stored: a number (or character string) calculated from the password.

Didactic classification

Subjective objective

The module introduces the fundamental principle of hash functions and their application in authentication systems. It develops a simplified procedure that converts the characters of a password into numerical values and combines them into a hash value. Learners structure the processing using loops and conditions and make clear decisions about handling different character types. In the second step, this model is transferred to a login scenario where only hash values are compared, not the plaintext. The connection between abstract security concepts and concrete implementation is in the foreground.

Competence development

Didactic added value in teaching

Lesson flow

1

Building a hash function (A=1…Z=26)

In this step, a simple hash function is developed that systematically processes the characters of a password. Only uppercase letters are considered, while other characters are deliberately ignored and the length of the original string is also taken into account.

  • Didactic focus: rule-based transformation of characters into numerical values
  • Typical challenge: consistent handling of different character types
2

Mini-login: compare hash instead of plaintext

Building on the hash function, a simple login system is implemented that only compares hash values. Both input and reference values are processed and the result of the check is made transparently.

  • Didactic focus: comparison logic and application of a model in an application context
  • Typical challenge: correct linking of hash calculation and decision structure

Work assignment (excerpt)

1. Develop a hash function for uppercase letters and establish clear rules
2. Systematically process characters and calculate numerical values
3. Implement a login procedure that compares hash values
4. Check results using test inputs and display them

Example (excerpt)

1
2
3
4
for ch in pw_upper:
    if 'A' <= ch <= 'Z':
        wert = ord(ch) - ord('A') + 1
        hash_wert += wert

This fragment shows the central conversion of characters into numerical values as the basis for hash formation.

Notes for classroom practice

This module links simple hash formation with login logic, making basic principles of password security understandable.

The clear structure supports step-by-step implementation and enables transparent result storage in the classroom.

Request a demo access and test the module in your own course context.