Last active
August 17, 2019 03:27
-
-
Save toomasv/ad30d5b9f7f6699fe83dc72ea723b97e to your computer and use it in GitHub Desktop.
(de)randomize argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Date: 16-Aug-2019 | |
See: {[August 15, 2019 9:56 PM](https://gitter.im/red/red?at=5d55aacd4e17537f5239de0c) forward} | |
Description: {Combined from @grggirwin's and @dockimbel's with some spice} | |
] | |
gen-hack2: function [ | |
{Generates randomly suffled copy of the argument and the seed to get it stright} | |
secret [any-string! any-block! binary!] | |
][ | |
random/seed stats | |
random/seed s: random len: length? masked: copy secret | |
random table: collect [repeat i len [keep i]] | |
repeat i len [poke masked table/:i pick secret i] | |
probe compose/only [random/seed (s) random ( | |
case [ | |
any-string? masked [as string! masked] | |
any-block? masked [to block! masked] | |
true [masked] | |
] | |
)] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment