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