The os_datablock component is OpenSecurity's utility data block. It offers a group of local data-processing callbacks such as Base64, compression, hashes, ROT13, and BCrypt helpers, and it also mounts a bundled filesystem environment named datablock.
- Repository:
opensecurity - Component name:
os_datablock - Typical host: placed OpenSecurity data block
local component = require("component")
local data = component.os_datablock
if not data then
error("os_datablock component not installed")
endWhen connected to a computer context, the block also exposes a bundled filesystem environment named datablock.
Several byte-array callbacks pass through a shared limiter:
- hard size limit:
Settings.get().dataCardHardLimit() - soft size limit:
Settings.get().dataCardSoftLimit() - timeout pause for oversized but still allowed data:
Settings.get().dataCardTimeout()
Shared failure modes for callbacks using that limiter:
- oversized input:
data size limit exceeded - insufficient power:
not enough energy
Energy classes used by the source:
- complex-cost callbacks:
encode64decode64deflateinflate
- simple-cost callbacks:
sha256md5crc32
- no limiter and no explicit power draw:
rot13bCryptHashbCryptCheck
- Syntax:
data.greet() - Returns:
string - Purpose: Returns the built-in OpenSecurity greeting.
- Syntax:
data.getLimit() - Returns:
number - Purpose: Returns the hard maximum byte size accepted by the limited callbacks.
- Syntax:
data.encode64(input) - Returns:
string - Purpose: Base64-encodes the supplied byte string.
Parameters:
input:string|byte[]
Behavior:
- The return value is a byte string containing ASCII Base64 text.
- Syntax:
data.decode64(input) - Returns:
string - Purpose: Base64-decodes the supplied byte string.
Parameters:
input:string|byte[]
Behavior:
- The return value is the decoded raw byte string.
- Syntax:
data.deflate(input) - Returns:
string - Purpose: Compresses the supplied bytes using deflate.
Parameters:
input:string|byte[]
- Syntax:
data.inflate(input) - Returns:
string - Purpose: Inflates a previously deflated byte string.
Parameters:
input:string|byte[]
- Syntax:
data.sha256(input) - Returns:
string - Purpose: Computes the SHA-256 digest.
Parameters:
input:string|byte[]
Behavior:
- The result is returned in binary format, not hexadecimal text.
- Syntax:
data.md5(input) - Returns:
string - Purpose: Computes the MD5 digest.
Parameters:
input:string|byte[]
Behavior:
- The result is returned in binary format.
- Syntax:
data.crc32(input) - Returns:
string - Purpose: Computes the CRC-32 digest.
Parameters:
input:string|byte[]
Behavior:
- The result is returned in binary format.
- Syntax:
data.rot13(input) - Returns:
string - Purpose: Applies ROT13 to alphabetic ASCII characters.
Parameters:
input:string
Behavior:
- Only letters
A-Zanda-zare rotated. - All other characters are copied unchanged.
- Syntax:
data.bCryptHash(plaintext[, rounds]) - Returns:
string - Purpose: Computes a BCrypt hash string.
Parameters:
plaintext:stringrounds:numberoptional
Behavior:
- Default rounds value is
10. - The implementation clamps rounds to
4through15. - The returned value is the standard BCrypt text hash.
- Syntax:
data.bCryptCheck(plaintext, hash) - Returns:
boolean - Purpose: Verifies plaintext against a BCrypt hash string.
Parameters:
plaintext:stringhash:string
local digest = data.sha256("hello")
local encoded = data.encode64("secret")
local compressed = data.deflate("compress me")
local hash = data.bCryptHash("password", 12)
print(#digest, encoded, data.bCryptCheck("password", hash))
print(data.rot13("uryyb jbeyq"))componentos_cardwriter