Skip to content

Latest commit

 

History

History
56 lines (21 loc) · 1.01 KB

Computer Security.md

File metadata and controls

56 lines (21 loc) · 1.01 KB

Computer Security

c

Computer security involves protecting computer systems and data from unauthorized access, theft, and damage. Understanding computer security is essential for developing software that is secure and resilient to attacks. Here's an example of a simple security program in Python using the cryptography library:

from cryptography.fernet import Fernet

Generate a key

key = Fernet.generate_key()

Store the key in a file

with open('key.txt', 'wb') as f:

f.write(key)

Load the key from the file

with open('key.txt', 'rb') as f:

key = f.read()

Create a Fernet object with the key

cipher = Fernet(key)

Encrypt a message

message = b'Hello, world!'

encrypted_message = cipher.encrypt(message)

print('Encrypted message:', encrypted_message)

Decrypt the message

decrypted_message = cipher.decrypt(encrypted_message)

print('Decrypted message:', decrypted_message)