crypto.SHA256
SHA256 object.
Constructor
crypto.SHA256(): crypto.SHA256Fields
| Name | Type | Description |
|---|---|---|
digest_size | integer | = 32 |
block_size | integer | = 64 |
digest | fun( message: string, as_hex: boolean? ): string |
Operators
| Operator | Operand | Result |
|---|---|---|
call | | crypto.SHA256 |
Static functions
#crypto.SHA256.digest
function crypto.SHA256.digest(message: string, as_hex?: boolean): string
Computes the SHA256 digest of the given input string.
This static method takes a string and returns its SHA256 hash as a hexadecimal string. Commonly used for checksums, data integrity validation, and password hashing.
| Name | Type | Description |
|---|---|---|
message | string | The message to compute SHA256 for. |
as_hexoptional | boolean | If true, the result will be a hex string. |
| Type | Name | Description |
|---|---|---|
string | str_result | The SHA256 string of the message. |
Methods
digest | Calculates the SHA256 digest based on the current state or input of the object. |
reset | Resets the SHA256 object to its initial state. |
update | Updates the SHA256 object with the given string. |
#SHA256:digest
function crypto.SHA256:digest(as_hex?: boolean): string
Calculates the SHA256 digest based on the current state or input of the object.
This instance method returns the SHA256 hash of the data associated with the object. Useful when the SHA256 object has been incrementally updated with input data.
Does not change the state, so the object can be updated further.
| Name | Type | Description |
|---|---|---|
as_hexoptional | boolean | If true, the result will be a hex string. |
| Type | Name | Description |
|---|---|---|
string | str_result | The SHA256 string of the message. |
#SHA256:reset
function crypto.SHA256:reset(): crypto.SHA256
Resets the SHA256 object to its initial state.
This instance method resets the SHA256 object to its initial state.
It returns the SHA256 object for method chaining.
| Type | Name | Description |
|---|---|---|
crypto.SHA256 | obj | The reset SHA256 object. |
#SHA256:update
function crypto.SHA256:update(str: string): crypto.SHA256
Updates the SHA256 object with the given string.
This instance method updates the SHA256 object with the given string.
It returns the SHA256 object for method chaining.
| Name | Type | Description |
|---|---|---|
str | string | The string to update the SHA256 object with. |
| Type | Name | Description |
|---|---|---|
crypto.SHA256 | obj | The updated SHA256 object. |