Skip to content

Commit 8eb294c

Browse files
committed
Use print instead of assert for crypto samples
1 parent 7508416 commit 8eb294c

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

docs/Runtime Environment/Crypto.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Hash a string using Lua's version of the DJB2 non-cryptographic hashing algorith
99
```pluto
1010
local crypto = require("crypto")
1111
local str = "hello world"
12-
assert(crypto.lua(str) == 2871868277)
12+
print(crypto.lua(str)) --> 2871868277
1313
```
1414
---
1515
### `crypto.djb2`
@@ -21,7 +21,7 @@ An integer between 0 and 0xffffffff, inclusive.
2121
```pluto
2222
local crypto = require("crypto")
2323
local str = "hello world"
24-
assert(crypto.djb2(str) == 894552257)
24+
print(crypto.djb2(str)) --> 894552257
2525
```
2626
---
2727
### `crypto.fnv1`
@@ -31,7 +31,7 @@ Hash a string using the FNV1 non-cryptographic hashing algorithm.
3131
```pluto
3232
local crypto = require("crypto")
3333
local str = "hello world"
34-
assert(crypto.fnv1(str) == 9065573210506989167)
34+
print(crypto.fnv1(str)) --> 9065573210506989167
3535
```
3636
---
3737
### `crypto.fnv1a`
@@ -41,7 +41,7 @@ Hash a string using the FNV1A non-cryptographic hashing algorithm.
4141
```pluto
4242
local crypto = require("crypto")
4343
local str = "hello world"
44-
assert(crypto.fnv1a(str) == 8618312879776256743)
44+
print(crypto.fnv1a(str)) --> 8618312879776256743
4545
```
4646
---
4747
### `crypto.joaat`
@@ -53,7 +53,7 @@ An integer between 0 and 0xffffffff, inclusive.
5353
```pluto
5454
local crypto = require("crypto")
5555
local str = "hello world"
56-
assert(crypto.joaat(str) == 1045060183)
56+
print(crypto.joaat(str)) --> 1045060183
5757
```
5858
---
5959
### `crypto.sdbm`
@@ -65,7 +65,7 @@ An integer between 0 and 0xffffffff, inclusive.
6565
```pluto
6666
local crypto = require("crypto")
6767
local str = "hello world"
68-
assert(crypto.sdbm(str) == 430867652)
68+
print(crypto.sdbm(str)) --> 430867652
6969
```
7070
---
7171
### `crypto.crc32`
@@ -78,7 +78,7 @@ An integer between 0 and 0xffffffff, inclusive.
7878
```pluto
7979
local crypto = require("crypto")
8080
local str = "hello world"
81-
assert(crypto.crc32(str) == 222957957)
81+
print(crypto.crc32(str)) --> 222957957
8282
```
8383
---
8484
### `crypto.crc32c`
@@ -91,7 +91,7 @@ An integer between 0 and 0xffffffff, inclusive.
9191
```pluto
9292
local crypto = require("crypto")
9393
local str = "hello world"
94-
assert(crypto.crc32c(str) == 3381945770)
94+
print(crypto.crc32c(str)) --> 3381945770
9595
```
9696
---
9797
### `crypto.adler32`
@@ -102,7 +102,7 @@ Hash a string using the Adler-32 non-cryptographic hashing algorithm.
102102
```pluto
103103
local crypto = require("crypto")
104104
local str = "hello"
105-
assert(crypto.adler32(str) == 103547413)
105+
print(crypto.adler32(str)) --> 103547413
106106
```
107107
---
108108
### `crypto.lookup3`
@@ -112,7 +112,7 @@ Hash a string using the Lookup3 non-cryptographic hashing algorithm.
112112
```pluto
113113
local crypto = require("crypto")
114114
local str = "hello world"
115-
assert(crypto.lookup3(str) == 1252609637)
115+
print(crypto.lookup3(str)) --> 1252609637
116116
```
117117
---
118118
### `crypto.times33`
@@ -124,7 +124,7 @@ An integer between 0 and 0xffffffff, inclusive.
124124
```pluto
125125
local crypto = require("crypto")
126126
local str = "hello world"
127-
assert(crypto.times33(str) == 3889643616)
127+
print(crypto.times33(str)) --> 3889643616
128128
```
129129
### `crypto.murmur1`
130130
Hash a string using the Murmur1 non-cryptographic hashing algorithm.
@@ -135,7 +135,7 @@ An integer between 0 and 0xffffffff, inclusive.
135135
```pluto
136136
local crypto = require("crypto")
137137
local str = "hello world"
138-
assert(crypto.murmur1(str) == 3154674178)
138+
print(crypto.murmur1(str)) --> 3154674178
139139
```
140140
---
141141
### `crypto.murmur2`
@@ -147,7 +147,7 @@ An integer between 0 and 0xffffffff, inclusive.
147147
```pluto
148148
local crypto = require("crypto")
149149
local str = "hello world"
150-
assert(crypto.murmur2(str) == 1151865881)
150+
print(crypto.murmur2(str)) --> 1151865881
151151
```
152152
### `crypto.murmur2a`
153153
Hash a string using the Murmur2A non-cryptographic hashing algorithm.
@@ -158,7 +158,7 @@ An integer between 0 and 0xffffffff, inclusive.
158158
```pluto
159159
local crypto = require("crypto")
160160
local str = "hello world"
161-
assert(crypto.murmur2a(str) == 2650573207)
161+
print(crypto.murmur2a(str)) --> 2650573207
162162
```
163163
### `crypto.murmur64a`
164164
Hash a string using the Murmur64A non-cryptographic hashing algorithm.
@@ -167,7 +167,7 @@ Hash a string using the Murmur64A non-cryptographic hashing algorithm.
167167
```pluto
168168
local crypto = require("crypto")
169169
local str = "hello world"
170-
assert(crypto.murmur64a(str) == -3190198453633110066)
170+
print(crypto.murmur64a(str)) --> -3190198453633110066
171171
```
172172
### `crypto.murmur64b`
173173
Hash a string using the Murmur64A non-cryptographic hashing algorithm.
@@ -176,7 +176,7 @@ Hash a string using the Murmur64A non-cryptographic hashing algorithm.
176176
```pluto
177177
local crypto = require("crypto")
178178
local str = "hello world"
179-
assert(crypto.murmur64b(str) == 7088720765356542432)
179+
print(crypto.murmur64b(str)) --> 7088720765356542432
180180
```
181181
---
182182
### `crypto.murmur2neutral`
@@ -186,7 +186,7 @@ Hash a string using the Murmur2Neutral non-cryptographic hashing algorithm.
186186
```pluto
187187
local crypto = require("crypto")
188188
local str = "hello world"
189-
assert(crypto.murmur2neutral(str) == 1151865881)
189+
print(crypto.murmur2neutral(str)) --> 1151865881
190190
```
191191
---
192192
## Semi-Cryptographic Hashing Algorithms
@@ -198,8 +198,8 @@ Hash a string using the MD5 semi-cryptographic hashing algorithm.
198198
```pluto
199199
local crypto = require("crypto")
200200
local str = "hello world"
201-
assert(crypto.md5(str) == "5eb63bbbe01eeed093cb22bb8f5acdc3")
202-
assert(crypto.md5(str, true) == "\x5e\xb6\x3b\xbb\xe0\x1e\xee\xd0\x93\xcb\x22\xbb\x8f\x5a\xcd\xc3")
201+
print(crypto.md5(str)) --> 5eb63bbbe01eeed093cb22bb8f5acdc3
202+
print(crypto.md5(str, true)) --> \x5e\xb6\x3b\xbb\xe0\x1e\xee\xd0\x93\xcb\x22\xbb\x8f\x5a\xcd\xc3
203203
```
204204
---
205205
## Cryptographic Hashing Algorithms
@@ -210,8 +210,8 @@ Hash a string using the SHA-1 cryptographic hashing algorithm.
210210
2. When set to true, returns raw binary data. false outputs lowercase hex digits. By default, this is false.
211211
```pluto
212212
local crypto = require("crypto")
213-
assert(crypto.sha1("Pluto") == "bce8c9aca4120776fad6b517874aa09c46405454")
214-
assert(crypto.sha1("Pluto", true) == "\xbc\xe8\xc9\xac\xa4\x12\x07\x76\xfa\xd6\xb5\x17\x87\x4a\xa0\x9c\x46\x40\x54\x54")
213+
print(crypto.sha1("Pluto")) --> bce8c9aca4120776fad6b517874aa09c46405454
214+
print(crypto.sha1("Pluto", true)) --> \xbc\xe8\xc9\xac\xa4\x12\x07\x76\xfa\xd6\xb5\x17\x87\x4a\xa0\x9c\x46\x40\x54\x54
215215
```
216216
---
217217
### `crypto.sha256`
@@ -221,8 +221,8 @@ Hash a string using the SHA-256 cryptographic hashing algorithm.
221221
2. When set to true, returns raw binary data. false outputs lowercase hex digits. By default, this is false.
222222
```pluto
223223
local crypto = require("crypto")
224-
assert(crypto.sha256("Pluto") == "8dad5f6a7dd2dcd8c35ec2fd7babb499bcad60d27d73fe73eca2ce025dfd3b47")
225-
assert(crypto.sha256("Pluto", true) == "\x8d\xad\x5f\x6a\x7d\xd2\xdc\xd8\xc3\x5e\xc2\xfd\x7b\xab\xb4\x99\xbc\xad\x60\xd2\x7d\x73\xfe\x73\xec\xa2\xce\x02\x5d\xfd\x3b\x47")
224+
print(crypto.sha256("Pluto")) --> 8dad5f6a7dd2dcd8c35ec2fd7babb499bcad60d27d73fe73eca2ce025dfd3b47
225+
print(crypto.sha256("Pluto", true)) --> \x8d\xad\x5f\x6a\x7d\xd2\xdc\xd8\xc3\x5e\xc2\xfd\x7b\xab\xb4\x99\xbc\xad\x60\xd2\x7d\x73\xfe\x73\xec\xa2\xce\x02\x5d\xfd\x3b\x47
226226
```
227227
---
228228
### `crypto.sha384`
@@ -232,7 +232,7 @@ Hash a string using the SHA-384 cryptographic hashing algorithm.
232232
2. When set to true, returns raw binary data. false outputs lowercase hex digits. By default, this is false.
233233
```pluto
234234
local crypto = require("crypto")
235-
assert(crypto.sha384("Pluto", false) == "db890233a919b6745d632633c419e14540ff79f1a89bc4ac194b00e7f913f0f06d5d4d7d6cc2b4aaf9485d223afb8cf0")
235+
print(crypto.sha384("Pluto", false)) --> db890233a919b6745d632633c419e14540ff79f1a89bc4ac194b00e7f913f0f06d5d4d7d6cc2b4aaf9485d223afb8cf0
236236
```
237237
---
238238
### `crypto.sha512`
@@ -242,7 +242,7 @@ Hash a string using the SHA-512 cryptographic hashing algorithm.
242242
2. When set to true, returns raw binary data. false outputs lowercase hex digits. By default, this is false.
243243
```pluto
244244
local crypto = require("crypto")
245-
assert(crypto.sha512("Pluto", false) == "ee8410a8bf9511b94fd6669b5c3e0c4b86e8e4bf7baa8dbd2773d4d6381dd1aecebbe391bef4c6158620ab3f6b794907652d4432c2301d7e1a6caf520565cdf2")
245+
print(crypto.sha512("Pluto", false)) --> ee8410a8bf9511b94fd6669b5c3e0c4b86e8e4bf7baa8dbd2773d4d6381dd1aecebbe391bef4c6158620ab3f6b794907652d4432c2301d7e1a6caf520565cdf2
246246
```
247247
---
248248
### `crypto.ripemd160`
@@ -251,7 +251,8 @@ Hash a string using the RIPEMD-160 cryptographic hashing algorithm.
251251
1. The string to hash.
252252
2. When set to true, returns raw binary data. false outputs lowercase hex digits. By default, this is false.
253253
```pluto
254-
assert(require"crypto".ripemd160("Pluto") == "c2072a85f4a691803b8942709036072086fd9550")
254+
local crypto = require("crypto")
255+
print(crypto.ripemd160("Pluto")) --> c2072a85f4a691803b8942709036072086fd9550
255256
```
256257
---
257258
## Cryptographic PRNGs

0 commit comments

Comments
 (0)