Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/migeyel/ccryptolib
A collection of cryptographic primitives for CC:Tweaked.
https://github.com/migeyel/ccryptolib
Last synced: about 2 months ago
JSON representation
A collection of cryptographic primitives for CC:Tweaked.
- Host: GitHub
- URL: https://github.com/migeyel/ccryptolib
- Owner: migeyel
- License: mit
- Created: 2023-06-08T04:22:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-01T02:14:39.000Z (8 months ago)
- Last Synced: 2024-08-04T02:07:42.412Z (5 months ago)
- Language: Lua
- Homepage:
- Size: 1.33 MB
- Stars: 11
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-switchcraft - ccryptolib - Collection of cryptographic primitives written in Lua (Libraries / Utility)
README
# CCryptoLib
An integrated collection of cryptographic primitives written in Lua using the ComputerCraft system API.## Initializing the Random Number Generator
All functions that take secret input may query the library's random generator,
`ccryptolib.random`. CC doesn't have high-quality entropy sources, so instead of
hoping for the best like other libraries do, CCryptoLib shifts that burden into
*you!*### Initializing using a Trusted Web Source
If you trust the tmpim Krist node, you can fetch a socket token and use it for
initialization:
```lua
local random = require "ccryptolib.random"-- Fetch a WebSocket token.
local postHandle = assert(http.post("https://krist.dev/ws/start", ""))
local data = textutils.unserializeJSON(postHandle.readAll())
postHandle.close()-- Initialize the generator using the given URL.
random.init(data.url)-- Be polite and actually open the socket too.
http.websocket(data.url).close()
```### Initializing using VM Instruction Counting
As of v1.2.0, you can also initialize the generator using VM instruction timing noise.
See the `random.initWithTiming` method for security risks of taking this approach.
```lua
local random = require "ccryptolib.random"
random.initWithTiming()
```