.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

 __init__ (self)
 
EngineResults post_search (self, "SXNG_Request" request, "SearchWithPlugins" search)
 
- Public Member Functions inherited from searx.plugins._core.Plugin
None __init__ (self)
 
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
typing id .ClassVar[str]
 
typing default_on .ClassVar[bool]
 
list keywords = []
 
logging log .Logger
 

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__()

searx.plugins.hash_plugin.SXNGPlugin.__init__ ( self)

Definition at line 28 of file hash_plugin.py.

28 def __init__(self):
29 super().__init__()
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("Converts strings to different hash digests."),
36 examples=["sha512 The quick brown fox jumps over the lazy dog"],
37 preference_section="query",
38 )
39

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

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