.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, 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 20 of file hash_plugin.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 28 of file hash_plugin.py.

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

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 42 of file hash_plugin.py.

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