You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-19Lines changed: 30 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,24 +4,35 @@
4
4
5
5
## Overview
6
6
7
-
**lua-cryptorandom** is a lightweight, native library for Lua aimed to generate cryptographically-secure pseudo-random bytes and numbers, using trusted sources of randomness provided by the operating system.
7
+
**lua-cryptorandom** is a lightweight, native library for Lua aimed to generate cryptographicallysecure pseudo random numbers, using trusted sources of randomness provided by the operating system.
8
8
9
-
* On Unix-like distributions, it uses the ```OpenSSL``` library to generate random bytes and numbers;
9
+
* On Unix-like distributions, it uses the ```OpenSSL``` library to generate random numbers;
10
10
* On Windows, it uses the WINAPI ```bcrypt``` library;
11
11
* On macOS / iOS, it uses the ```Security``` framework.
12
12
13
13
> [!NOTE]
14
14
>
15
15
> ```lua-cryptorandom``` is implemented in C, and also compiles as C++.
16
16
17
+
## Use cases
18
+
19
+
Many security operations rely on the high-quality of randomization services to avoid reproducibility and remain resistant to reverse engineering:
20
+
21
+
* randomized password generation;
22
+
* nonces (numbers used once) generation;
23
+
* initialization vectors;
24
+
* salts in passwords before hashing;
25
+
* tokenization (*token generation*) to represent sensitive data;
> For each method below, always check whether the first returned value is ```nil``` or not. When the first value is ```nil```, there was an underlying error generating random values. It can fail because no trusted random source is available or the trusted source temporarily fail to provide sufficient randomness material.
72
+
> For each method below, always check whether the first returned value is ```nil``` or not. When the first value is ```nil```, there was an underlying error generating random values. It can fail because no trusted random source is available or the trusted entropy source temporarily fail to provide sufficient randomness material.
**Return*: ```table | nil``` as first value, and ```nil | number``` as the second.
70
-
1.```table | nil```: a table containing ```n``` bytes on success, or ```nil``` when an error occurred;
71
-
2.```nil | integer```: an error code that is set to ```nil``` on success, or an ```integer``` representing the code used by the underlying library (```OpenSSL``` on Unix, ```bcrypt``` on Windows and ```Security``` framework on macOS / iOS).
81
+
*```table | nil```: a table containing ```n``` bytes on success, or ```nil``` when an error occurred;
82
+
*```nil | integer```: an error code that is set to ```nil``` on success, or an ```integer``` representing the code used by the underlying library (```OpenSSL``` on Unix, ```bcrypt``` on Windows and ```Security``` framework on macOS / iOS).
72
83
**Remark*: Here, a byte is meant as an integer in the range 0 - 255.
summary=[[Generate cryptographically-secure pseudo-random bytes and numbers for Lua]],
11
+
summary=[[Generate cryptographicallysecure pseudo random numbers for Lua]],
12
12
detailed=[=[
13
-
lua-cryptorandom is a lightweight, native library for Lua aimed to generate cryptographically-secure pseudo-random bytes and numbers, using trusted sources of randomness provided by the operating system.
13
+
lua-cryptorandom is a lightweight, native library for Lua aimed to generate cryptographicallysecure pseudo random numbers, using trusted sources of randomness provided by the operating system.
summary=[[Generate cryptographically-secure pseudo-random bytes and numbers for Lua]],
10
+
summary=[[Generate cryptographicallysecure pseudo random numbers for Lua]],
11
11
detailed=[=[
12
-
lua-cryptorandom is a lightweight, native library for Lua aimed to generate cryptographically-secure pseudo-random bytes and numbers, using trusted sources of randomness provided by the operating system.
12
+
lua-cryptorandom is a lightweight, native library for Lua aimed to generate cryptographicallysecure pseudo random numbers, using trusted sources of randomness provided by the operating system.
0 commit comments