tobogganSe connecter

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.

21 lignes · 656 octetsBrut · Historique
1// A ChaCha20-Poly1305 key is 32 bytes: another length stops the actor, on
2// both backends (ADR 0071).
3
4import std/bytes
5import std/crypto
6import std/io
7import std/string
8
9pub 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