You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 88df782
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/pages/guessing.md
+21-12Lines changed: 21 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,12 @@ The following parameters are tunable:
11
11
-`stop_func`: can be a function or a regular expression to be matched (automatically converted to a function that uses the `re` module) ; by default, checks if all input characters are printable.
12
12
-`min_depth`: the minimum depth for the tree search (allows to avoid a bit of overhead while checking the current decoded output at a depth with the stop function when we are sure it should not be the right result) ; by default 0.
13
13
-`max_depth`: the maximum depth for the tree search ; by default 5.
14
-
-`codec_categories`: a string indicating a codec [category](features.md#list-codecs) or a list of [category](features.md#list-codecs) strings ; by default, `None`, meaning the whole [categories](features.md#list-codecs) (very slow).
14
+
-`include`: the [categories](features.md#list-codecs), codecs or encodings to be considered, as a single name, a list of names or a dictionary of lists of names per depth (from 0, -1 meaning any depth) ; by default, `None`, meaning all of them (very slow).
15
+
-`exclude`: the [categories](features.md#list-codecs), codecs or encodings not to be considered, in the same formats ; by default, `None`, meaning none of them.
15
16
-`found`: a list or tuple of currently found encodings that can be used to save time if the first decoding steps are known ; by default, an empty tuple.
16
17
18
+
The result is a dictionary of the decoded strings by tuple of encodings, in order of application.
19
+
17
20
A simple example for a 1-stage base64-encoded string:
18
21
19
22
```python
@@ -25,7 +28,7 @@ An example of a 2-stages base64- then base62-encoded string:
25
28
26
29
```python
27
30
>>> codext.guess("CJG3Ix8bVcSRMLOqwDUg28aDsT7")
28
-
{('base62',): 'VGhpcyBpcyBhIHRlc3Q='}
31
+
{('chaocipher',): 'NGH3Hb8tYyJWGEEseSOq28aTtS7'}
29
32
```
30
33
31
34
In the second example, we can see that the given encoded string is not decoded as expected. This is the case because the (default) stop condition is too broad and stops if all the characters of the output are printable. If we have a prior knowledge on what we should expect, we can input a simple string or a regex:
@@ -43,37 +46,43 @@ In the second example, we can see that the given encoded string is not decoded a
43
46
{('base62', 'base64'): 'This is a test'}
44
47
```
45
48
46
-
In this example, the string "*test*" is converted to a function that uses this string as regular expression. Instead of a string, we can also pass a function. For this purpose, standard [stop functions](#available-stop-functions) are predefined. So, we can for instance use `stopfunc.lang_en` to stop when we find something that is English. Note that working this way gives lots of false positives if the text is very short like in the example case. That's why the `codec_categories` argument is used to only consider baseX codecs. This is also demonstrated in the next examples.
49
+
In this example, the string "*test*" is converted to a function that uses this string as regular expression. Instead of a string, we can also pass a function. For this purpose, standard [stop functions](#available-stop-functions) are predefined. So, we can for instance use `stopfunc.lang_en` to stop when we find something that is English. Note that working this way gives lots of false positives if the text is very short like in the example case. That's why the `include` argument is used to only consider baseX codecs. This is also demonstrated in the next examples.
If we are sure that only `base` (which is a valid [category](features.md#list-codecs)) encodings are used, we can restrict the tree search using the `codec_categories` parameter to save time:
64
+
If we are sure that only `base` (which is a valid [category](features.md#list-codecs)) encodings are used, we can restrict the tree search using the `include` parameter to save time, or even give the encodings to be considered at each depth, while the `exclude` parameter removes some of them:
With the [CLI tool](cli.md), these parameters are given with the `-i`/`--include` and `-e`/`--exclude` options, the names being possibly prefixed with a depth (e.g. `codext guess -i 0:base62 1:base64`).
85
+
77
86
When multiple results are expected, `stop` and `show` arguments can be used respectively to avoid stopping while finding a result and to display the intermediate result.
0 commit comments