louise
The Louise language: compiler, runtime, std, tooling
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#125 · main · 16 min 13 s
0Étoiles
0Forks
40Issues
| 1 | // A ChaCha20-Poly1305 key is 32 bytes: another length stops the actor, on |
| 2 | // both backends (ADR 0071). |
| 3 | |
| 4 | import std/bytes |
| 5 | import std/crypto |
| 6 | import std/io |
| 7 | import std/string |
| 8 | |
| 9 | pub fn main :: -> () / <io> |
| 10 | { |
| 11 | let key = bytes.from_string (string.repeat "k" 32) |
| 12 | let nonce = bytes.from_string (string.repeat "n" 12) |
| 13 | let message = bytes.from_string "m" |
| 14 | io.println |
| 15 | "{bytes.length (crypto.chacha20_poly1305_seal key nonce message message)}" |
| 16 | let short = bytes.slice key 0 31 |
| 17 | io.println |
| 18 | "never printed {bytes.length (crypto.chacha20_poly1305_seal short nonce message message)}" |
| 19 | } |
| 20 | //> 17 |
| 21 | //! panic: crypto: a ChaCha20-Poly1305 key is 32 bytes, not 31 |