Skip to content

Commit 6f9dfa3

Browse files
authored
Add examples/README.md (#55)
Describe each example program so readers can pick the right starting point. Ordered simplest to most involved, matching the ponylang examples convention. Closes #48
1 parent d381aae commit 6f9dfa3

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

examples/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Examples
2+
3+
Each subdirectory is a self-contained Pony program demonstrating a
4+
different part of the ssl library. Ordered from simplest to most
5+
involved: the hashing examples come first, the SSL networking example
6+
follows.
7+
8+
## [hash-fn-example](hash-fn-example/)
9+
10+
Computes MD5, SHA1, and SHA256 hashes of a string in a single call each
11+
and prints the results. Shows the one-shot convenience functions `MD5`,
12+
`SHA1`, and `SHA256` from `ssl/crypto`, plus `ToHexString` for
13+
formatting the resulting `Array[U8] val`. Start here if you're new to
14+
the library.
15+
16+
## [digest-example](digest-example/)
17+
18+
Hashes data in chunks using the streaming `Digest` API. Creates a
19+
`Digest.sha256()`, appends two string pieces with `append()`, and
20+
finalizes with `final()` to produce the hash. Also demonstrates
21+
`Digest.shake256(n)` for variable-length output on OpenSSL 3.0.x and
22+
4.0.x, guarded by an `ifdef`.
23+
24+
## [ssl-client-server-example](ssl-client-server-example/)
25+
26+
Runs a TLS client and server in the same process, exchanging a few
27+
messages over a loopback TCP connection. Demonstrates setting up an
28+
`SSLContext` with `set_authority`, `set_cert`, and verification toggled
29+
off, then wrapping both sides of a `TCPConnection` with `SSLConnection`
30+
from `ssl/net`. Requires an `assets/cert.pem` and `assets/key.pem`
31+
alongside the example — see the source comments for how the relative
32+
paths are resolved.

0 commit comments

Comments
 (0)