Skip to content

Instantly share code, notes, and snippets.

@toomasv
Last active August 17, 2019 03:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toomasv/ad30d5b9f7f6699fe83dc72ea723b97e to your computer and use it in GitHub Desktop.
Save toomasv/ad30d5b9f7f6699fe83dc72ea723b97e to your computer and use it in GitHub Desktop.
(de)randomize argument
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