HSL 2.0 framework
Description of the framework
Public Member Functions |List of all members
hsl20_4_crypto.hsl20_4_crypto.SHA2Hash Class Reference

Class for generating a SHA-2 hash value. More..

Public Member Functions

def__init__ (self, size=512)
Constructor. More...
defupdate (self, data)
Updates the SHA2 hash value with the transferred data. More...
defdigest (self)
Returns the SHA2 code. More...
defhex_digest (self)
Returns the SHA2 code as a hex string. More...

Detailed Description

Class to generate a SHA-2 hash value

Part of the packet for encryption

class Crypto_HASH(hsl20_4.BaseModule):
def __init__(self, homeserver_context):
....
def on_input_value(self, index, value):
if index == self.PIN_I_DO_HASH:
if value == 1:
hash = self.FRAMEWORK.create_sha224_hash()
elif value == 2:
hash = self.FRAMEWORK.create_sha256_hash()
elif value == 3:
hash = self.FRAMEWORK.create_sha384_hash()
else:
hash = self.FRAMEWORK.create_sha512_hash()
hash.update(self._get_input_value(self.PIN_I_DATA))
self._set_output_value(self.PIN_O_HEXCODE, hash.hex_digest())

If a telegram is received at input PIN_I_DO_HASH, a hash code is formed for the data block (string) at input PIN_I_DATA. Depending on the value of the telegram it is selected which method is used for this. Then at output PIN_O_HEXCODE the hash code is output as a hexadecimal number

Constructor & Destructor Documentation

◆ __init__()

def hsl20_4_crypto.hsl20_4_crypto.SHA2Hash.__init__ ( self,
size = 512
)

Constructor

Parameters
sizeint
Length of the hash value. Possible values: 224, 256, 384 and 512

Member Function Documentation

◆ digest()

def hsl20_4_crypto.hsl20_4_crypto.SHA2Hash.digest ( self)

Returns the SHA2 code

Returns
string
SHA2 code

◆ hex_digest()

def hsl20_4_crypto.hsl20_4_crypto.SHA2Hash.hex_digest ( self)

Returns the SHA2 code as a hex string

Returns
string
SHA2 code

◆ update()

def hsl20_4_crypto.hsl20_4_crypto.SHA2Hash.update ( self,
data
)

Updates the SHA2 hash value with the transferred data

Parameters
datastring
Data block

The documentation for this class was generated from the following file: