MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / asteriskText

Function asteriskText

botasaurus/string_utils.py:24–50  ·  view source on GitHub ↗
(inp)

Source from the content-addressed store, hash-verified

22 return data
23
24def asteriskText(inp):
25 from random import randint
26 from math import ceil
27
28 if not inp: # Do nothing if no string passed
29 return ""
30 rep="*"
31
32 arr = list(inp) # Convert String to Array
33 len_arr = len(arr)
34
35 if len_arr <= 2:
36 i = 1
37 else:
38 i = ceil(len_arr / 2)
39
40 i = min(i, len_arr) # Ensure i doesn't exceed the array length
41
42 done = set()
43 while i > 0:
44 r = randint(0, len_arr - 1)
45 if r in done:
46 continue
47 arr[r] = rep
48 done.add(r)
49 i -= 1
50 return "".join(arr)
51
52def hide_text_with_asterisk(data, exceptKeys=[]):
53 """

Callers 1

hide_text_with_asteriskFunction · 0.85

Calls 2

addMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected