Skip to content

CLI tool for swapping bytes using pattern and mask written in Rust

License

Notifications You must be signed in to change notification settings

PicoJr/bswp-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BSWP-CLI

Another unpronounceable tool.

Swap bytes using patterns and masks.

Usage

USAGE:
    bswp-cli [OPTIONS] -e <pattern>...

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -i <input>             input path (if not provided STDIN is used instead)
    -o <output>            output path (if not provided STDOUT is used instead)
    -e <pattern>...        pattern: <value>,<mask>,<periodicity>,<offset>

Replace every other bytes by 0x42 (displayed as B).

echo -n "AAAA" | bswp-cli -e 0x42,0xFF,2,0

result:

BABA

Replace every other 4 bytes groups by 0x52555354 (displayed as RUST)

echo -n "AAAABBBBCCCCDDDD" | bswp-cli -e 0x52,0xFF,8,0 -e 0x55,0xFF,8,1 -e 0x53,0xFF,8,2 -e 0x54,0xFF,8,3

result:

RUSTBBBBRUSTDDDD

Tests

Run tests with cargo test.

Build From Source

Clone and build from source:

git clone https://github.com/PicoJr/bswp-cli.git
cd bswp-cli
cargo build --release

Performances

yes | head -c 100MiB | ./target/release/bswp-cli -e 0x6e,0xFF,2,1 | pv > /dev/null
 100MiB 0:00:00 [ 147MiB/s] [   <=>
pattern(s) throughput
1 ~150MiB/s
2 ~75MiB/s
3 ~50MiB/s
4 ~40MiB/s

Changelog

Please see the CHANGELOG for a release history.

About

CLI tool for swapping bytes using pattern and mask written in Rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages