banner
andrewji8

Being towards death

Heed not to the tree-rustling and leaf-lashing rain, Why not stroll along, whistle and sing under its rein. Lighter and better suited than horses are straw sandals and a bamboo staff, Who's afraid? A palm-leaf plaited cape provides enough to misty weather in life sustain. A thorny spring breeze sobers up the spirit, I feel a slight chill, The setting sun over the mountain offers greetings still. Looking back over the bleak passage survived, The return in time Shall not be affected by windswept rain or shine.
telegram
twitter
github

Shocking Python Automation Scripts You Must Try (4)

  1. Password Manager This automation script helps you manage all your passwords, making them secure and accessible only to you, using different encryption techniques.
# Import required libraries
import streamlit as st
import csv
from cryptography.fernet import Fernet
from cryptography.fernet import InvalidToken

# Custom encryption key (hard-coded)
CUSTOM_ENCRYPTION_KEY = b'u7wGgNdDFefqpr_kGxb8wJf6XRVsRwvb3QgITsD5Ft4='  
# If you plan to use this script on a shared platform, make sure to keep this key in a separate secure file.

# Function to encrypt password
def encrypt_password(password):
    cipher_suite = Fernet(CUSTOM_ENCRYPTION_KEY)
    encrypted_password = cipher_suite.encrypt(password.encode())  # Encrypt the password after encoding
    return encrypted_password

# Function to decrypt password
def decrypt_password(encrypted_password):
    if isinstance(encrypted_password, bytes):  # Check if the encrypted password is of bytes type
        try:
            cipher_suite = Fernet(CUSTOM_ENCRYPTION_KEY)
            decrypted_password = cipher_suite.decrypt(encrypted_password)  # Decrypt
            return decrypted_password.decode()  # Decode bytes to string
        except InvalidToken:
            return "Invalid Token"  # Return invalid token message if the key is incorrect
    else:
        return None

# Function to save website name and password to CSV file
def save_credentials(website_name, password):
    encrypted_password = encrypt_password(password)  # Encrypt the password first
    with open('credentials.csv', 'a', newline='') as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow([website_name, encrypted_password.decode()])  # Store the encrypted password as a string after decoding

# Function to retrieve password from CSV file
def retrieve_password(website_name):
    with open('credentials.csv', 'r') as csvfile:
        reader = csv.reader(csvfile)
        for row in reader:
            if row[0] == website_name:
                encrypted_password = row[1].encode()  # Re-encode to bytes
                return encrypted_password
    return None

# Create web interface using Streamlit
st.title("Password Manager")

# Input fields for entering website name and password
website_name = st.text_input("Enter website name:")
password = st.text_input("Enter password:", type="password")

# Save button to save website name and password
if st.button("Save"):
    if website_name and password:
        save_credentials(website_name, password)
        st.success("Website name and password have been successfully saved.")
    else:
        st.error("Please fill in all fields.")

# Retrieve button to retrieve password
if st.checkbox("Retrieve password"):
    website_name = st.selectbox("Select website name:", options=[""] + [row[0] for row in csv.reader(open('credentials.csv', 'r'))])
    key = st.text_input("Enter your encryption key:", type="password")
    if st.button("Retrieve password"):
        if key == str(CUSTOM_ENCRYPTION_KEY.decode()):
            if website_name:
                encrypted_password = retrieve_password(website_name)
                if encrypted_password:
                    decrypted_password = decrypt_password(encrypted_password)
                    st.success(f"The password for website **{website_name}** -> **{decrypted_password}**")
                else:
                    st.error("Password not found in the database.")
        elif key == "":
            pass
        else:
            st.error("Invalid encryption key!")

image

  1. Bulk Email Sender This automation script uses Gmail's own SMTP server to send bulk emails in just a few minutes, allowing you to fully customize and take control.
# Import smtplib library for email transmission
import smtplib
# Import ssl library to establish a secure connection
import ssl

# SMTP server details
smtp_server = 'smtp.gmail.com'  # The SMTP server address for Gmail
smtp_port = 465  # The port number used, Gmail's SSL port is 465

# Sender and receiver details
from_address = 'yuhualong Shop'  # Sender's address or name
to_address = ['', '']  # List of recipients, can add multiple recipient email addresses

# Authentication information
username = ''  # Sender's email account
password = ''  # Sender's email password

# Email content details
subject = '🎉 Exclusive Offer! Enjoy a 10% discount on your next purchase'
body = '''\
Dear Customer,

As our valued customer, to express our gratitude, we are offering you an exclusive discount on your next purchase. Use the discount code below at checkout to enjoy a 10% discount on your order:

Discount Code: DISCOUNT888

Whether you're looking for stylish apparel, trendy accessories, or high-quality products, now is the best time to shop and save! Explore our latest collection and treat yourself to something special. Hurry! This offer is limited time only. Don't miss the chance to save on your favorite items.

Shop now: https://xyz.com

Thank you for choosing yuhualong Shop. We look forward to serving you again soon!

Best wishes,
yuhualong Shop
'''

# Create an SSL/TLS context
context = ssl.create_default_context()

# Connect via SMTP server using SSL/TLS
with smtplib.SMTP_SSL(smtp_server, smtp_port, context=context) as server:
    # Enable debug level to print server response information
    server.set_debuglevel(1)
    # Log in to the SMTP server
    server.login(username, password)
    # Create email message
    message = f'From: {from_address}\r\nSubject: {subject}\r\nTo: {", ".join(to_address)}\r\n\r\n{body}'
    message = message.encode()  # Convert message to byte format
    # Send email
    server.sendmail(from_address, to_address, message)
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.