Skip to content

Commit 476b3a4

Browse files
committed
generate random password
1 parent b349190 commit 476b3a4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

misc/generate_password.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
with init(len, arr) as (
2+
select 16, string_to_array('23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ&#%@', null)
3+
), arrlen(l) as (
4+
select count(*)
5+
from (select unnest(arr) from init) _
6+
), indexes(i) as (
7+
select 1 + int4(random() * (l - 1))
8+
from arrlen, (select generate_series(1, len) from init) _
9+
)
10+
select array_to_string(array_agg(arr[i]), '') as password
11+
from init, indexes
12+
;
13+

0 commit comments

Comments
 (0)