forked from opensearch-project/security
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds random password generation capability to demo config install scr…
…ipts Signed-off-by: Darshit Chanpura <[email protected]>
- Loading branch information
1 parent
bfba97a
commit 24e8cd2
Showing
4 changed files
with
65 additions
and
14 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@echo off | ||
setlocal enableDelayedExpansion | ||
|
||
REM Set the directory of the current script | ||
set "SCRIPT_DIR=%~dp0" | ||
|
||
REM Set the desired password length | ||
set "length=16" | ||
|
||
REM Define the character set for the password | ||
set "characters=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" | ||
|
||
REM Initialize the password variable | ||
set "password=" | ||
|
||
REM Loop to generate the random password | ||
for /l %%i in (1,1,%length%) do ( | ||
set /a "index=!random! %% 62" | ||
for %%c in (!index!) do ( | ||
set "char=!characters:~%%c,1!" | ||
set "password=!password!!char!" | ||
) | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
length="$1" | ||
if [ -z "$length" ]; then | ||
length=12 # Default password length | ||
fi | ||
|
||
# Define the character set for the password | ||
characters="A-Za-z0-9" | ||
|
||
# Use /dev/urandom to generate random bytes and tr to shuffle them | ||
LC_ALL=C tr -dc "$characters" < /dev/urandom | head -c "$length" |
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
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