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