Quick Start Guide¶
This guide will help you get started with usenc quickly.
Basic Usage¶
Command Line¶
The basic syntax is:
Encode from stdin¶
Decode¶
Use the -d or --decode flag:
File Input/Output¶
Read from and write to files:
# Encode file
usenc url -i input.txt -o output.txt
# Decode file
usenc url -d -i encoded.txt -o decoded.txt
Piping¶
usenc works great with Unix pipes:
# Encode and decode in a pipeline
echo "test data" | usenc url | usenc url -d
# Process multiple lines
cat file.txt | usenc url > encoded.txt
Encoder-Specific Options¶
Each encoder may have its own options. Use --help after the encoder name to see them:
For example, the url encoder takes --include and --exclude options
Advanced examples¶
echo "hello world" | usenc hex --prefix '${' --suffix '}' --exclude ' '
# Output: ${68}${65}${6C}${6C}${6F} ${77}${6F}${72}${6C}${64}
Python API¶
Basic Encoding¶
from usenc import encode, decode
# Encode
encoded = encode('hello world', 'url')
print(encoded) # hello%20world
# Decode
decoded = decode(encoded, 'url')
print(decoded) # hello world
With Parameters¶
from usenc import encode, decode
# Include additional characters
encoded = encode('hello-world', 'url', include='-')
print(encoded) # hello%2Dworld
# Exclude characters from encoding
encoded = encode('path/to/file', 'url', exclude='/')
print(encoded) # path/to/file
Common Use Cases¶
Encoding parameters to use in URL¶
echo "name=John Doe&email=john@example.com" | usenc url
# Output: name%3DJohn%20Doe%26email%3Djohn%40example.com
Binary files to text¶
Batch Processing¶
usenc url -i wordlist.txt -o url_encoded_wordlist.txt
usenc html -i wordlist.txt -o html_escaped_wordlist.txt
Insert string in source code¶
Hash sum of file¶
Next Steps¶
- Learn about all available Encoders
- Check the API Reference
- Add your own encoder