File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,18 @@ local function shuffle(tb)
108108 end
109109 return tb
110110end
111+ local function shuffle_string (str )
112+ local len = # str
113+ local t = {}
114+ for i = 1 , len do
115+ t [i ] = string.sub (str , i , i )
116+ end
117+ for i = 1 , len do
118+ local j = math.random (i , len )
119+ t [i ], t [j ] = t [j ], t [i ]
120+ end
121+ return table.concat (t )
122+ end
111123
112124local function readDouble (bytes )
113125 local sign = 1
@@ -255,6 +267,7 @@ return {
255267 chararray = chararray ,
256268 keys = keys ,
257269 shuffle = shuffle ,
270+ shuffle_string = shuffle_string ,
258271 readDouble = readDouble ,
259272 writeDouble = writeDouble ,
260273 readU16 = readU16 ,
@@ -270,4 +283,4 @@ return {
270283 toBits = toBits ,
271284 bytesToString = bytesToString ,
272285 readonly = readonly ,
273- }
286+ }
You can’t perform that action at this time.
0 commit comments