git ssb

2+

cel / scuttlebot.io



Tree: 254c89b83aef67583e5b1b6f6cd5fdba4fb0b493

Files: 254c89b83aef67583e5b1b6f6cd5fdba4fb0b493 / tmpl / docs / basics / encryption.html.js

1388 bytesRaw
1var page = require('../../page.part')
2var com = require('../../com.part')
3
4module.exports = () => page({
5 section: 'docs',
6 tab: 'docs-basics',
7 path :'/docs/basics/encryption.html',
8 content: `
9 <h2>Publish an Encrypted Message</h2>
10 ${ com.code({ js: jsSnippet1 }) }
11 <h2>Decrypt a Message</h2>
12 ${ com.code({ js: jsSnippet2 })}
13 <h2>Is a message encrypted?</h2>
14 ${ com.code({ js: jsSnippet3 })}
15 <p class="next"><a href="/docs/social/follow-users.html">Follow users</a></p>
16 <ul class="see-also">
17 <li><a href="/advanced/private-box.html">Private Box</a></li>
18 <li><a href="/advanced/linking-messages.html">Linking messages</a></li>
19 </ul>
20 `
21})
22
23var jsSnippet1 = `
24sbot.private.publish(
25 // message:
26 {
27 type: 'post',
28 text: 'Hello, friend!'
29 },
30 // recipient PKs:
31 [
32 '@hxGxqPrplLjRG2vtj...wQpS730nNwE=.ed25519',
33 '@EMovhfIrFk4NihAKn...8pTxJNgvCCY=.ed25519'
34 ],
35 // cb:
36 function (err, privateMsg) {
37 // privateMsg.value.content is
38 // an encrypted string
39 }
40)
41`
42
43var jsSnippet2 = `
44sbot.private.unbox(
45 privateMsg.value.content,
46 function (err, content) {
47 // 'content' is now an object
48 // (if you were a recipient)
49 }
50)
51`
52
53var jsSnippet3 = `
54function isPlaintext (msg) {
55 return (typeof msg.value.content == 'object')
56}
57function isEncrypted (msg) {
58 return (typeof msg.value.content == 'string')
59}
60`

Built with git-ssb-web