diff options
| author | Timothy Pearson <tpearson@raptorengineering.com> | 2018-06-02 14:44:30 -0500 |
|---|---|---|
| committer | Timothy Pearson <tpearson@raptorengineering.com> | 2018-06-03 04:51:36 -0500 |
| commit | 3e7dedf3f2ed30cdf38663d361bde2599102f149 (patch) | |
| tree | b9efb2eb4ef6cd099c03aa849de033a8a1a96bee /woferclock/find_replace_binary_string | |
| parent | a9ae58c7402d14c018a29f956a545b49ff030363 (diff) | |
| download | vpdtools-3e7dedf3f2ed30cdf38663d361bde2599102f149.tar.gz vpdtools-3e7dedf3f2ed30cdf38663d361bde2599102f149.zip | |
Add WoFerClock utility
Diffstat (limited to 'woferclock/find_replace_binary_string')
| -rwxr-xr-x | woferclock/find_replace_binary_string | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/woferclock/find_replace_binary_string b/woferclock/find_replace_binary_string new file mode 100755 index 0000000..bcea1d8 --- /dev/null +++ b/woferclock/find_replace_binary_string @@ -0,0 +1,27 @@ +#!/usr/bin/python +# +# Copyright (c) 2018 Raptor Engineering, LLC +# Released under the terms of the AGPL v3 + +import sys +import binascii + +filename = sys.argv[1] +searchfile = sys.argv[2] +replacefile = sys.argv[3] + +with open(filename, 'rb') as f: + indata = f.read() +with open(searchfile, 'rb') as f: + searchdata = f.read() +with open(replacefile, 'rb') as f: + replacedata = f.read() + +raw_data = binascii.hexlify(indata) +search = binascii.hexlify(searchdata) +replace = binascii.hexlify(replacedata) +raw_data = raw_data.replace(search, replace) +outdata = binascii.unhexlify(raw_data) + +with open(filename, 'wb') as f: + f.write(outdata) |

