on 87fbd5e help sign in
835 lines 20 kB history raw
1+++
2title = "3d: SHA Hash Family"
3weight = 24
4template = "doc.html"
5+++
7## `++shad`
9Double SHA-256
11Produces an atom that is twice-hashed with `shax`, the SHA-256 cryptographic
12hash algorithm.
14#### Accepts
16`ruz` is an atom.
18#### Produces
20An atom.
22#### Source
24```hoon
25 ++ shad |=(ruz=@ (shax (shax ruz)))
26```
28#### Examples
30```
31 > (shad 11)
32 \/20.519.637.820.582.103.109.435.907.615.585.653.479.776.629.591.855.451.248.\/
33 718.295.626.625.655.417.234
34```
36---
38## `++shaf`
40Half SHA-256
42Produces a 128-bit atom by performing the [bitwise XOR](/docs/hoon/reference/stdlib/2d) on the
43first and last halves of the 256-bit salted hash `shas`.
45#### Accepts
47`sal` is an atom.
49`ruz` is an atom.
51#### Source
53```hoon
54 ++ shaf :: half sha-256
55 |= [sal=@ ruz=@]
56 =+ haz=(shas sal ruz)
57 (mix (end 7 1 haz) (rsh 7 1 haz))
58```
60#### Examples
62```
63 > (shaf 17 8)
64 52.667.672.807.485.289.251.324.336.639.183.409.041
66 > `@ub`(shaf 17 8)
67 \/0b1011.1111.1101.0110.1110.1000.0100.1110.1100.1000.0010.0100.1111.0001.0010.0010\/
68 .0100.1110.1110.0011.1100.1111.0001.1101.1101.1100.1110.1111.0100.0101.0001.0100
69 \/
70```
72---
74## `++shal`
76SHA-512 with length
78Produces an atom by hashing an atom `ruz` with SHA-512. Another atom, `len`, is
79the byte-length of the theoretical buffer represented by the atom.
81#### Accepts
83`len` is an atom.
85`ruz` is an atom.
87#### Produces
89An atom.
91#### Source
93```hoon
94 ++ shal
95 ~/ %shal
96 |= [len=@ ruz=@] ^- @
97 => .(ruz (cut 3 [0 len] ruz))
98 =+ [few==>(fe .(a 6)) wac=|=([a=@ b/@] (cut 6 [a 1] b))]
99 =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few]
100 =+ ral=(lsh 0 3 len)
101 =+ ^= ful
102 %+ can 0
103 :~ [ral ruz]
104 [8 128]
105 [(mod (sub 1.920 (mod (add 8 ral) 1.024)) 1.024) 0]
106 [128 (~(net fe 7) ral)]
107 ==
108 =+ lex=(met 10 ful)
109 =+ ^= kbx 0x6c44.198c.4a47.5817.5fcb.6fab.3ad6.faec.
110 597f.299c.fc65.7e2a.4cc5.d4be.cb3e.42b6.
111 431d.67c4.9c10.0d4c.3c9e.be0a.15c9.bebc.
112 32ca.ab7b.40c7.2493.28db.77f5.2304.7d84.
113 1b71.0b35.131c.471b.113f.9804.bef9.0dae.
114 0a63.7dc5.a2c8.98a6.06f0.67aa.7217.6fba.
115 f57d.4f7f.ee6e.d178.eada.7dd6.cde0.eb1e.
116 d186.b8c7.21c0.c207.ca27.3ece.ea26.619c.
117 c671.78f2.e372.532b.bef9.a3f7.b2c6.7915.
118 a450.6ceb.de82.bde9.90be.fffa.2363.1e28.
119 8cc7.0208.1a64.39ec.84c8.7814.a1f0.ab72.
120 78a5.636f.4317.2f60.748f.82ee.5def.b2fc.
121 682e.6ff3.d6b2.b8a3.5b9c.ca4f.7763.e373.
122 4ed8.aa4a.e341.8acb.391c.0cb3.c5c9.5a63.
123 34b0.bcb5.e19b.48a8.2748.774c.df8e.eb99.
124 1e37.6c08.5141.ab53.19a4.c116.b8d2.d0c8.
125 106a.a070.32bb.d1b8.f40e.3585.5771.202a.
126 d699.0624.5565.a910.d192.e819.d6ef.5218.
127 c76c.51a3.0654.be30.c24b.8b70.d0f8.9791.
128 a81a.664b.bc42.3001.a2bf.e8a1.4cf1.0364.
129 9272.2c85.1482.353b.81c2.c92e.47ed.aee6.
130 766a.0abb.3c77.b2a8.650a.7354.8baf.63de.
131 5338.0d13.9d95.b3df.4d2c.6dfc.5ac4.2aed.
132 2e1b.2138.5c26.c926.27b7.0a85.46d2.2ffc.
133 1429.2967.0a0e.6e70.06ca.6351.e003.826f.
134 d5a7.9147.930a.a725.c6e0.0bf3.3da8.8fc2.
135 bf59.7fc7.beef.0ee4.b003.27c8.98fb.213f.
136 a831.c66d.2db4.3210.983e.5152.ee66.dfab.
137 76f9.88da.8311.53b5.5cb0.a9dc.bd41.fbd4.
138 4a74.84aa.6ea6.e483.2de9.2c6f.592b.0275.
139 240c.a1cc.77ac.9c65.0fc1.9dc6.8b8c.d5b5.
140 efbe.4786.384f.25e3.e49b.69c1.9ef1.4ad2.
141 c19b.f174.cf69.2694.9bdc.06a7.25c7.1235.
142 80de.b1fe.3b16.96b1.72be.5d74.f27b.896f.
143 550c.7dc3.d5ff.b4e2.2431.85be.4ee4.b28c.
144 1283.5b01.4570.6fbe.d807.aa98.a303.0242.
145 ab1c.5ed5.da6d.8118.923f.82a4.af19.4f9b.
146 59f1.11f1.b605.d019.3956.c25b.f348.b538.
147 e9b5.dba5.8189.dbbc.b5c0.fbcf.ec4d.3b2f.
148 7137.4491.23ef.65cd.428a.2f98.d728.ae22
149 =+ ^= hax 0x5be0.cd19.137e.2179.1f83.d9ab.fb41.bd6b.
150 9b05.688c.2b3e.6c1f.510e.527f.ade6.82d1.
151 a54f.f53a.5f1d.36f1.3c6e.f372.fe94.f82b.
152 bb67.ae85.84ca.a73b.6a09.e667.f3bc.c908
153 =+ i=0
154 |- ^- @
155 ?: =(i lex)
156 (rep 6 (turn (rip 6 hax) net))
157 =+ ^= wox
158 =+ dux=(cut 10 [i 1] ful)
159 =+ wox=(rep 6 (turn (rip 6 dux) net))
160 =+ j=16
161 |- ^- @
162 ?: =(80 j)
163 wox
164 =+ :* l=(wac (sub j 15) wox)
165 m=(wac (sub j 2) wox)
166 n=(wac (sub j 16) wox)
167 o=(wac (sub j 7) wox)
168 ==
169 =+ x=:(mix (ror 0 1 l) (ror 0 8 l) (rsh 0 7 l))
170 =+ y=:(mix (ror 0 19 m) (ror 0 61 m) (rsh 0 6 m))
171 =+ z=:(sum n x o y)
172 $(wox (con (lsh 6 j z) wox), j +(j))
173 =+ j=0
174 =+ :* a=(wac 0 hax)
175 b=(wac 1 hax)
176 c=(wac 2 hax)
177 d=(wac 3 hax)
178 e=(wac 4 hax)
179 f=(wac 5 hax)
180 g=(wac 6 hax)
181 h=(wac 7 hax)
182 ==
183 |- ^- @
184 ?: =(80 j)
185 %= ^$
186 i +(i)
187 hax %+ rep 6
188 :~ (sum a (wac 0 hax))
189 (sum b (wac 1 hax))
190 (sum c (wac 2 hax))
191 (sum d (wac 3 hax))
192 (sum e (wac 4 hax))
193 (sum f (wac 5 hax))
194 (sum g (wac 6 hax))
195 (sum h (wac 7 hax))
196 ==
197 ==
198 =+ l=:(mix (ror 0 28 a) (ror 0 34 a) (ror 0 39 a)) :: S0
199 =+ m=:(mix (dis a b) (dis a c) (dis b c)) :: maj
200 =+ n=(sum l m) :: t2
201 =+ o=:(mix (ror 0 14 e) (ror 0 18 e) (ror 0 41 e)) :: S1
202 =+ p=(mix (dis e f) (dis (inv e) g)) :: ch
203 =+ q=:(sum h o p (wac j kbx) (wac j wox)) :: t1
204 $(j +(j), a (sum q n), b a, c b, d c, e (sum d q), f e, g f, h g)
205```
207#### Examples
209```
210 > (shal 1 'hello')
211 \/7.956.615.373.791.575.273.027.009.123.631.914.645.972.441.264.528.176.292.399.908\/
212 .424.469.676.078.106.561.839.264.176.650.109.335.825.608.088.511.266.620.100.157.
213 847.055.280.028.606.252.747.432.021.213.474
214 \/
216 > (shal 1 'hello')
217 \/7.956.615.373.791.575.273.027.009.123.631.914.645.972.441.264.528.176.292.399.908\/
218 .424.469.676.078.106.561.839.264.176.650.109.335.825.608.088.511.266.620.100.157.
219 847.055.280.028.606.252.747.432.021.213.474
220 \/
221```
223#### Discussion
225Because byte-strings can have leading zeros, but atoms cannot, we use `len`
226as a way of saying that the atom `ruz` is shorter than its representative
227byte-string.
229---
231## `++sham`
233128-bit noun hash
235Produces a 128-bit atom by hashing a noun `yux` with the `shah` function. If
236that noun is a cell, then it is passed to the [`jam`](/docs/hoon/reference/stdlib/2p) function to produce
237an atom to be hashed.
239#### Accepts
241`yux` is a noun.
243#### Produces
245An atom.
247#### Source
249```hoon
250 ++ sham
251 |= yux=* ^- @uvH ^- @
252 ?@ yux
253 (shaf %mash yux)
254 (shaf %sham (jam yux))
255 ::
256```
258#### Examples
260```
261 > (sham [2 4])
262 0v3.71s52.4bqnp.ki2b8.9hhsp.2ufgg
264 > (sham "hello")
265 0v1.hg8mv.t7s3f.u4f8a.q5noe.dvqvh
266```
268---
270## `++shan`
272SHA-1
274Produces an atom by hashing an atom `ruz` with SHA-1.
276#### Accepts
278`ruz` is an atom.
280#### Produces
282An atom.
284#### Source
286```hoon
287 ++ shan
288 |= ruz=@
289 =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))]
290 =+ [sum=sum.few ror=ror.few rol=rol.few net=net.few inv=inv.few]
291 =+ ral=(lsh 0 3 (met 3 ruz))
292 =+ ^= ful
293 %+ can 0
294 :~ [ral ruz]
295 [8 128]
296 [(mod (sub 960 (mod (add 8 ral) 512)) 512) 0]
297 [64 (~(net fe 6) ral)]
298 ==
299 =+ lex=(met 9 ful)
300 =+ kbx=0xca62.c1d6.8f1b.bcdc.6ed9.eba1.5a82.7999
301 =+ hax=0xc3d2.e1f0.1032.5476.98ba.dcfe.efcd.ab89.6745.2301
302 =+ i=0
303 |-
304 ?: =(i lex)
305 (rep 5 (flop (rip 5 hax)))
306 =+ ^= wox
307 =+ dux=(cut 9 [i 1] ful)
308 =+ wox=(rep 5 (turn (rip 5 dux) net))
309 =+ j=16
310 |- ^- @
311 ?: =(80 j)
312 wox
313 =+ :* l=(wac (sub j 3) wox)
314 m=(wac (sub j 8) wox)
315 n=(wac (sub j 14) wox)
316 o=(wac (sub j 16) wox)
317 ==
318 =+ z=(rol 0 1 :(mix l m n o))
319 $(wox (con (lsh 5 j z) wox), j +(j))
320 =+ j=0
321 =+ :* a=(wac 0 hax)
322 b=(wac 1 hax)
323 c=(wac 2 hax)
324 d=(wac 3 hax)
325 e=(wac 4 hax)
326 ==
327 |- ^- @
328 ?: =(80 j)
329 %= ^$
330 i +(i)
331 hax %+ rep 5
332 :~
333 (sum a (wac 0 hax))
334 (sum b (wac 1 hax))
335 (sum c (wac 2 hax))
336 (sum d (wac 3 hax))
337 (sum e (wac 4 hax))
338 ==
339 ==
340 =+ fx=(con (dis b c) (dis (not 5 1 b) d))
341 =+ fy=:(mix b c d)
342 =+ fz=:(con (dis b c) (dis b d) (dis c d))
343 =+ ^= tem
344 ?: &((gte j 0) (lte j 19))
345 :(sum (rol 0 5 a) fx e (wac 0 kbx) (wac j wox))
346 ?: &((gte j 20) (lte j 39))
347 :(sum (rol 0 5 a) fy e (wac 1 kbx) (wac j wox))
348 ?: &((gte j 40) (lte j 59))
349 :(sum (rol 0 5 a) fz e (wac 2 kbx) (wac j wox))
350 :(sum (rol 0 5 a) fy e (wac 3 kbx) (wac j wox))
351 $(j +(j), a tem, b a, c (rol 0 30 b), d c, e d)
352```
354#### Examples
356```
357 > (shan 'hello')
358 975.987.071.262.755.080.377.722.350.727.279.193.143.145.743.181
359```
361#### Discussion
363SHA-1 is a deprecated function; it is not considered secure.
365---
367## `++shas`
369Salted hash
371Produces an atom by using SHA-256 plus a salt input. The [bitwise XOR](/docs/hoon/reference/stdlib/2d)
372is performed on `sal` and the product of `ruz` hashed with SHA-256. The product
373of that logical operation is then itself hashed with SHA-256.
375#### Accepts
377`sal` is an atom.
379`ruz` is an atom.
381#### Source
383```hoon
384 ++ shas
385 |= [sal=@ ruz=@]
386 (shax (mix sal (shax ruz)))
387```
389#### Examples
391```
392 > (shas 12.845 6)
393 \/111.115.941.493.032.291.043.932.789.632.248.509.108.945.255.494.251.860.287\/
394 .707.279.709.200.349.471.936
395 \/
396```
398---
400## `++shaw`
402Hash to nbits
404Produces an atom of `len` random bits by hashing `ruz` with the salted
405SHA-256 hash algorithm, where `sal` is the cryptographic salt.
407#### Accepts
409`sal` is an atom.
411`len` is an atom.
413`ruz` is an atom.
415#### Produces
417An atom.
419#### Source
421```hoon
422 ++ shaw
423 |= [sal=@ len=@ ruz=@]
424 (~(raw og (shas sal (mix len ruz))) len)
425```
427#### Examples
429```
430 > `@ub`(shaw 3 6 98)
431 0b11.0111
433 > `@ub`(shaw 2 6 98)
434 0b11
435```
437---
439## `++shax`
441SHA-256
443Produces an atom by hashing an atom `ruz` with SHA-256.
445#### Sources
447```hoon
448 ++ shax
449 ~/ %shax
450 |= ruz=@ ^- @
451 (shay [(met 3 ruz) ruz])
452```
454#### Examples
456```
457 > (shax 'hello')
458 \/16.552.786.619.039.860.277.601.417.878.457.384.195.409.020.923.835.016.617.984.82\/
459 0.774.431.701.725.740
460 \/
461```
463---
465## `++shay`
467SHA-256 with length
469Produces an atom by hashing an atom `ruz` with SHA-512. Another atom, `len`, is
470the byte-length of the theoretical buffer represented by the atom.
472#### Accepts
474`len` is an atom.
476`ruz` is an atom.
478#### Source
480```hoon
481 ++ shay
482 ~/ %shay
483 |= [len=@u ruz=@] ^- @
484 => .(ruz (cut 3 [0 len] ruz))
485 =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))]
486 =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few]
487 =+ ral=(lsh 0 3 len)
488 =+ ^= ful
489 %+ can 0
490 :~ [ral ruz]
491 [8 128]
492 [(mod (sub 960 (mod (add 8 ral) 512)) 512) 0]
493 [64 (~(net fe 6) ral)]
494 ==
495 =+ lex=(met 9 ful)
496 =+ ^= kbx 0xc671.78f2.bef9.a3f7.a450.6ceb.90be.fffa.
497 8cc7.0208.84c8.7814.78a5.636f.748f.82ee.
498 682e.6ff3.5b9c.ca4f.4ed8.aa4a.391c.0cb3.
499 34b0.bcb5.2748.774c.1e37.6c08.19a4.c116.
500 106a.a070.f40e.3585.d699.0624.d192.e819.
501 c76c.51a3.c24b.8b70.a81a.664b.a2bf.e8a1.
502 9272.2c85.81c2.c92e.766a.0abb.650a.7354.
503 5338.0d13.4d2c.6dfc.2e1b.2138.27b7.0a85.
504 1429.2967.06ca.6351.d5a7.9147.c6e0.0bf3.
505 bf59.7fc7.b003.27c8.a831.c66d.983e.5152.
506 76f9.88da.5cb0.a9dc.4a74.84aa.2de9.2c6f.
507 240c.a1cc.0fc1.9dc6.efbe.4786.e49b.69c1.
508 c19b.f174.9bdc.06a7.80de.b1fe.72be.5d74.
509 550c.7dc3.2431.85be.1283.5b01.d807.aa98.
510 ab1c.5ed5.923f.82a4.59f1.11f1.3956.c25b.
511 e9b5.dba5.b5c0.fbcf.7137.4491.428a.2f98
512 =+ ^= hax 0x5be0.cd19.1f83.d9ab.9b05.688c.510e.527f.
513 a54f.f53a.3c6e.f372.bb67.ae85.6a09.e667
514 =+ i=0
515 |- ^- @
516 ?: =(i lex)
517 (rep 5 (turn (rip 5 hax) net))
518 =+ ^= wox
519 =+ dux=(cut 9 [i 1] ful)
520 =+ wox=(rep 5 (turn (rip 5 dux) net))
521 =+ j=16
522 |- ^- @
523 ?: =(64 j)
524 wox
525 =+ :* l=(wac (sub j 15) wox)
526 m=(wac (sub j 2) wox)
527 n=(wac (sub j 16) wox)
528 o=(wac (sub j 7) wox)
529 ==
530 =+ x=:(mix (ror 0 7 l) (ror 0 18 l) (rsh 0 3 l))
531 =+ y=:(mix (ror 0 17 m) (ror 0 19 m) (rsh 0 10 m))
532 =+ z=:(sum n x o y)
533 $(wox (con (lsh 5 j z) wox), j +(j))
534 =+ j=0
535 =+ :* a=(wac 0 hax)
536 b=(wac 1 hax)
537 c=(wac 2 hax)
538 d=(wac 3 hax)
539 e=(wac 4 hax)
540 f=(wac 5 hax)
541 g=(wac 6 hax)
542 h=(wac 7 hax)
543 ==
544 |- ^- @
545 ?: =(64 j)
546 %= ^$
547 i +(i)
548 hax %+ rep 5
549 :~ (sum a (wac 0 hax))
550 (sum b (wac 1 hax))
551 (sum c (wac 2 hax))
552 (sum d (wac 3 hax))
553 (sum e (wac 4 hax))
554 (sum f (wac 5 hax))
555 (sum g (wac 6 hax))
556 (sum h (wac 7 hax))
557 ==
558 ==
559 =+ l=:(mix (ror 0 2 a) (ror 0 13 a) (ror 0 22 a)) :: s0
560 =+ m=:(mix (dis a b) (dis a c) (dis b c)) :: maj
561 =+ n=(sum l m) :: t2
562 =+ o=:(mix (ror 0 6 e) (ror 0 11 e) (ror 0 25 e)) :: s1
563 =+ p=(mix (dis e f) (dis (inv e) g)) :: ch
564 =+ q=:(sum h o p (wac j kbx) (wac j wox)) :: t1
565 $(j +(j), a (sum q n), b a, c b, d c, e (sum d q), f e, g f, h g)
566```
568#### Examples
570```
571 > (shay 1 'hello')
572 \/16.144.219.278.061.159.438.339.586.294.967.166.038.336.988.797.862.808.055.174.98\/
573 7.398.597.302.069.674
574 \/
576 > (shay 2 'hello')
577 \/100.467.333.538.737.303.691.714.735.404.408.035.555.613.179.595.938.688.113.300.8\/
578 01.974.878.934.544.183
579 \/
580```
582#### Discussion
584Because byte-strings can have leading zeros, but atoms cannot, we use `len`
585as a way of saying that the atom `ruz` is shorter than its representative
586byte-string.
588---
590## `++shaz`
592SHA-512
594Produces an atom by hashing an atom `ruz` with SHA-512.
596#### Accepts
598`ruz` is an atom.
600#### Produces
602An atom.
604#### Source
606```hoon
607 ++ shaz
608 |= ruz=@ ^- @
609 (shal [(met 3 ruz) ruz])
610```
612#### Examples
614```
615 > (shaz 'hello')
616 \/3.548.533.422.469.437.734.729.094.584.175.910.682.076.656.883.559.953.324.378.007\/
617 .735.849.386.038.666.450.748.109.671.344.747.196.048.200.348.948.408.339.256.384.
618 360.070.359.656.053.016.948.640.159.265.179
619 \/
620```
622---
624## `++og`
626Container arm for SHA-256-powered random-number generation. Its sample `a` is an
627atom that is used as a seed for the hash.
629#### Accepts
631`a` is an atom.
633#### Produces
635A core.
637#### Source
639```hoon
640 ++ og
641 ~/ %og
642 |_ a=@
643```
645#### Examples
647```
648 > ~(. og 919)
649 <4.wmp {a/@ud <54.tyv 119.olq 31.ohr 1.jmk $143>}>
650```
652#### Discussion
654Note that the product is deterministic; the seed will produce the same
655result every time it is run. Use `eny`, 256 bits of entropy, for a
656non-deterministic product.
658---
660### `++rad:og`
662Random in range
664Produces a random number that is within the range of first `b` whole numbers,
665starting at `0`.
667#### Accepts
669`b` is an atom.
671#### Produces
673An atom.
675#### Source
677```hoon
678 ++ rad
679 |= b=@ ^- @
680 =+ c=(raw (met 0 b))
681 ?:((lth c b) c $(a +(a)))
682```
684#### Examples
686```
687 > (~(rad og 5) 11)
688 4
690 > (~(rad og 758.716.593) 11)
691 2
693 > (~(rad og 1) 100.000)
694 71.499
696 > (~(rad og eny) 11) :: `eny` acts as a random sample
697 7
698```
700---
702### `++rads:og`
704Random continuation
706Produces a cell. The head of the cell is a random number that is within the
707range of first `b` whole numbers, starting at `0`. The tail is a new core
708produced from hashing the parent core with `(rad b)`.
710#### Accepts
712`b` is an atom.
714#### Produces
716A cell.
718#### Source
720```hoon
721 ++ rads
722 |= b=@
723 =+ r=(rad b)
724 [r +>.$(a (shas %og-s (mix a r)))]
725```
727#### Examples
729```
730 > (~(rads og 4) 10)
731 [2 <4.wmp {a/@ <54.tyv 119.olq 31.ohr 1.jmk $143>}>]
733 > =/ rng ~(. og 7)
734 =^ a rng (rads:rng 10)
735 =^ b rng (rads:rng 10)
736 [a b]
737 [2 8]
738```
740#### Discussion
742Since everything in Hoon is a pure function, we need to use tricks like this to
743generate separate random values from the same seed. Notice how we jump from
744one `rads` function call to another in the above example.
746---
748### `++raw:og`
750Random bits
752Produces an atom with a bitwidth `b` that is composed of random bits.
754#### Accepts
756`b` is an atom.
758#### Produces
760An atom.
762#### Source
764```hoon
765 ++ raw
766 ~/ %raw
767 |= b=@ ^- @
768 %+ can
769 0
770 =+ c=(shas %og-a (mix b a))
771 |- ^- (list [@ @])
772 ?: =(0 b)
773 ~
774 =+ d=(shas %og-b (mix b (mix a c)))
775 ?: (lth b 256)
776 [[b (end 0 b d)] ~]
777 [[256 d] $(c d, b (sub b 256))]
778```
780#### Examples
782```
783 > `@ud`(~(raw og 27) 4)
784 0b1001
786 > `@ub`(~(raw og 27) 3)
787 0b0
789 > `@ub`(~(raw og 11) 4)
790 0b1111
792 > `@ub`(~(raw og 11) 3)
793 0b100
794```
796---
798### `++raws:og`
800Random bits continuation
802Produces a cell. The head of the cell is an atom with a bitwidth `b` that is
803composed of random bits. The tail is a new core produced from hashing the
804parent core with `(raw b)`.
806#### Source
808```hoon
809 ++ raws
810 |= b=@
811 =+ r=(raw b)
812 [r +>.$(a (shas %og-s r))]
813 --
814```
816#### Examples
818```
819 > `[@ub _og]`(~(raws og 7) 4)
820 [0b1100 <4.wmp {a/@ <54.tyv 119.olq 31.ohr 1.jmk $143>}>]
822 > =/ rng ~(. og 7)
823 =^ a rng (rads:rng 4)
824 =^ b rng (rads:rng 4)
825 [`@ub`a `@ub`b]
826 [0b10 0b1]
827```
829#### Discussion
831Since everything in Hoon is a pure function, we need to use tricks like this to
832generate separate random values from the same seed. Notice how we jump from
833one `raws` function call to another in the above example.
835---