.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.plugins.hash_plugin.SXNGPlugin Class Reference
Inheritance diagram for searx.plugins.hash_plugin.SXNGPlugin:
Collaboration diagram for searx.plugins.hash_plugin.SXNGPlugin:

Public Member Functions

None __init__ (self, "PluginCfg" plg_cfg)
EngineResults post_search (self, "SXNG_Request" request, "SearchWithPlugins" search)
Public Member Functions inherited from searx.plugins._core.Plugin
None __init__ (self, "PluginCfg" plg_cfg)
int __hash__ (self)
 __eq__ (self, typing.Any other)
bool init (self, "flask.Flask" app)
bool pre_search (self, SXNG_Request request, "SearchWithPlugins" search)
bool on_result (self, SXNG_Request request, "SearchWithPlugins" search, Result result)

Public Attributes

 parser_re = re.compile(f"({'|'.join(self.keywords)}) (.*)", re.I)
 info

Additional Inherited Members

Static Public Attributes inherited from searx.plugins._core.Plugin
str id = ""
typing active .ClassVar[bool]
list keywords = []
logging log .Logger
str fqn = ""

Detailed Description

Plugin converts strings to different hash digests.  The results are
displayed in area for the "answers".

Definition at line 19 of file hash_plugin.py.

Constructor & Destructor Documentation

◆ __init__()

None searx.plugins.hash_plugin.SXNGPlugin.__init__ ( self,
"PluginCfg" plg_cfg )

Definition at line 27 of file hash_plugin.py.

27 def __init__(self, plg_cfg: "PluginCfg") -> None:
28 super().__init__(plg_cfg)
29
30 self.parser_re = re.compile(f"({'|'.join(self.keywords)}) (.*)", re.I)
31 self.info = PluginInfo(
32 id=self.id,
33 name=gettext("Hash plugin"),
34 description=gettext(
35 "Converts strings to different hash digests. Available functions: md5, sha1, sha224, sha256, sha384, sha512." # pylint:disable=line-too-long
36 ),
37 examples=["sha512 The quick brown fox jumps over the lazy dog"],
38 preference_section="query",
39 )
40

References __init__().

Referenced by __init__().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ post_search()

EngineResults searx.plugins.hash_plugin.SXNGPlugin.post_search ( self,
"SXNG_Request" request,
"SearchWithPlugins" search )
Returns a result list only for the first page.

Reimplemented from searx.plugins._core.Plugin.

Definition at line 41 of file hash_plugin.py.

41 def post_search(self, request: "SXNG_Request", search: "SearchWithPlugins") -> EngineResults:
42 """Returns a result list only for the first page."""
43 results = EngineResults()
44
45 if search.search_query.pageno > 1:
46 return results
47
48 m = self.parser_re.match(search.search_query.query)
49 if not m:
50 # wrong query
51 return results
52
53 function, string = m.groups()
54 if not string.strip():
55 # end if the string is empty
56 return results
57
58 # select hash function
59 f = hashlib.new(function.lower())
60
61 # make digest from the given string
62 f.update(string.encode("utf-8").strip())
63 answer = function + " " + gettext("hash digest") + ": " + f.hexdigest()
64
65 results.add(results.types.Answer(answer=answer))
66
67 return results

References parser_re.

Member Data Documentation

◆ info

searx.plugins.hash_plugin.SXNGPlugin.info
Initial value:
= PluginInfo(
id=self.id,
name=gettext("Hash plugin"),
description=gettext(
"Converts strings to different hash digests. Available functions: md5, sha1, sha224, sha256, sha384, sha512." # pylint:disable=line-too-long
),
examples=["sha512 The quick brown fox jumps over the lazy dog"],
preference_section="query",
)

Definition at line 31 of file hash_plugin.py.

◆ parser_re

searx.plugins.hash_plugin.SXNGPlugin.parser_re = re.compile(f"({'|'.join(self.keywords)}) (.*)", re.I)

Definition at line 30 of file hash_plugin.py.

Referenced by post_search().


The documentation for this class was generated from the following file:
  • /home/andrew/Documents/code/public/searxng/searx/plugins/hash_plugin.py