Companies like Google and Facebook always obfuscate the website Html classes. You can easily use obfuscated codes in anywhere like Static sites, CMS like WordPress, or sites created with Flask.
If you know Python basics and you want to obfuscate your website code. This tutorial is definitely going o help you a lot.
SEE ALSO: .htaccess Security Tips: Prevent Website from Hacking
So how to obfuscate Html classes using Python?
Then create a Python file named app.py
Install the html-classes-obfuscater package via the following pip command.
pip install html-classes-obfuscator
Then put the following code inside app.py file.
import glob import random import string from html_classes_obfuscator import html_classes_obfuscator htmlfiles = glob.glob("./**/*.html", recursive=True) cssfiles = glob.glob("./**/*.css", recursive=True) jsfiles = glob.glob("./**/*.js", recursive=True) print(htmlfiles) print(cssfiles) print(jsfiles) # Generate random string def generate_class(current_classes_list): def random_class(): # Offers (26*2)^6 random class name possibilities return ''.join(random.choice(string.ascii_letters) for i in range(6)) res = random_class() while res in current_classes_list.values(): res = random_class() return res html_classes_obfuscator.html_classes_obfuscator(htmlfiles, cssfiles, jsfiles, generate_class)
Now run that file. It will automatically replace the origins Html, CSS, and js files with the obfuscated version of the file.