Module
Module documentation.
modulecrypto.sha1
Classes
Classes and inheritance.
Functions
Free functions and class methods.
functioncrypto.sha1::byte
Signature
func byte(n: Int) -> Stringfunc byte(n: Int) -> String {
return encoding.byte_from_code(n & 255);
}@briefProvides the system library operation `byte`.
@detailsExecutes the `byte` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- nCount, size, or limit value.
@returnReturns the operation result as `String`.
functioncrypto.sha1::byte_at
Signature
func byte_at(s: String, idx: Int) -> Intfunc byte_at(s: String, idx: Int) -> Int {
return std.byte_at(s, idx) & 255;
}@briefProvides the system library operation `byte_at`.
@detailsExecutes the `byte_at` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- sInput string.
- idxZero-based index.
@returnReturns the operation result as `Int`.
functioncrypto.sha1::u32_be
Signature
func u32_be(n: Int) -> Stringfunc u32_be(n: Int) -> String {
return byte((n >> 24) & 255)
+ byte((n >> 16) & 255)@briefProvides the system library operation `u32_be`.
@detailsExecutes the `u32_be` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- nCount, size, or limit value.
@returnReturns the operation result as `String`.
functioncrypto.sha1::mask32
Signature
func mask32(n: Int) -> Intfunc mask32(n: Int) -> Int {
return n & 4294967295;
}@briefProvides the system library operation `mask32`.
@detailsExecutes the `mask32` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- nCount, size, or limit value.
@returnReturns the operation result as `Int`.
functioncrypto.sha1::rol32
Signature
func rol32(n: Int, bits: Int) -> Intfunc rol32(n: Int, bits: Int) -> Int {
let x: Int = mask32(n);
return mask32((x << bits) | (x >> (32 - bits)));@briefProvides the system library operation `rol32`.
@detailsExecutes the `rol32` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- nCount, size, or limit value.
- bitsBit count, bit mask, or encoded bits consumed by the operation.
@returnReturns the operation result as `Int`.
functioncrypto.sha1::pad
Signature
func pad(data: String) -> Stringfunc pad(data: String) -> String {
let bit_len: Int = std.len(data) * 8;
let out: String = data + byte(128);@briefProvides the system library operation `pad`.
@detailsExecutes the `pad` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- dataInput or output data buffer.
@returnReturns the operation result as `String`.
functioncrypto.sha1::word
Signature
func word(block: String, off: Int) -> Intfunc word(block: String, off: Int) -> Int {
return (byte_at(block, off) << 24)
| (byte_at(block, off + 1) << 16)@briefProvides the system library operation `word`.
@detailsExecutes the `word` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- blockBlock size, callback block, or blocking-mode flag used by the operation.
- offZero-based byte offset or element offset at which the operation starts.
@returnReturns the operation result as `Int`.
functioncrypto.sha1::sum
Signature
func sum(data: String) -> Stringfunc sum(data: String) -> String {
let msg: String = pad(data);
let state_a: Int = 1732584193;@briefProvides the system library operation `sum`.
@detailsExecutes the `sum` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- dataInput or output data buffer.
@returnReturns the operation result as `String`.
Variables
Class fields (var).