Practical 1 — Encryption, Decryption and Hashing

Aim
Encrypt/decrypt text with a shift cipher and generate a password hash using bcrypt.

Code: shift cipher
```python
def encrypt(text, s):
    result = ""
    for char in text:
        base = ord('A') if char.isupper() else ord('a')
        result += chr((ord(char) - base + s) % 26 + base)
    return result

def decrypt(text, s):
    return encrypt(text, -s)

text = "attackontitan"
shift = 5
cipher = encrypt(text, shift)
print("Text:", text)
print("Encrypted:", cipher)
print("Decrypted:", decrypt(cipher, shift))
```

Hashing with bcrypt
```python
import bcrypt
password = b'Mypass'
salt = bcrypt.gensalt()
hashed = bcrypt.hashpw(password, salt)
print("Salt:", salt)
print("Hash:", hashed)
```

Key point: encryption is reversible with the key; a hash is one-way.
