Obfuscate class names in HTML, CSS and Javascript files.
Project description
👋 HTML-Classes-Obfuscator 🔒
CLI tool that obfuscates HTML classes:
Normal HTML file :
<div class="card w-50">
<div class="card-body">Hello World</div>
</div>
Obfuscated HTML file :
<div class="oywdon tgmvkg">
<div class=emnpzm>Hello World</div>
</div>
🚀 Usage
Via command line...
git clone git@github.com:xandermann/html-classes-obfuscator.git
cp html-classes-obfuscator/html_classes_obfuscator/html_classes_obfuscator.py ./YOUR_PROJECT
python3 html_classes_obfuscator.py --htmlpath="**/*.html" --csspath="**/*.css" --jspath="**/*.js"
...Or via a python script
# https://pypi.org/project/html-classes-obfuscator/
pip install html-classes-obfuscator
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)
⚠️️ Important notes
- Make a backup before use.
- DON'T use if you have duplicate class names in your css files.
- If you modify the class generator, be sure that the generated name doesn’t begin with a number:
In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier “B&W?” may be written as “B&W?” or “B\26 W\3F”. https://www.w3.org/TR/CSS21/syndata.html#characters
✅ Run tests
python3 -m unittest tests/*.py
🤝 Contributing
Contributions, issues and feature requests are welcome.
Feel free to check issues page if you want to contribute.
Check the contributing guide.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file html_classes_obfuscator-1.0.1.tar.gz
.
File metadata
- Download URL: html_classes_obfuscator-1.0.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9385e75b87206728c0f8aa43245cd3a47aab794f2bec1f8365109fefc7b2757 |
|
MD5 | 4de7a036750dfdef8df17830e1436c00 |
|
BLAKE2b-256 | adb689dd47b7a2ce6e194cc201ee79aae8fb682cfdd1c1693031c341e37ddc0d |
File details
Details for the file html_classes_obfuscator-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: html_classes_obfuscator-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 636c6ebae3eabb3a146809f94283b3af7388c53b474640fcf650b2d6a6951c85 |
|
MD5 | ed52802c9cf87a8e0270b381d933f2c4 |
|
BLAKE2b-256 | 1ac58d095e625b04b75d19ecc5f8238e5f1ce87b0fc29c556c5bf234d1ecf2f7 |