gpt4 book ai didi

bash - 如何生成不带某些字符或允许某些字符集的 openssl 河豚

转载 作者:行者123 更新时间:2023-12-02 19:01:26 26 4
gpt4 key购买 nike

我有以下 bash 脚本,可以将blowfish 自动插入到 phpMyAdmin 的 config.inc.php 中:

#!/bin/bash

randomBlowfishSecret=$(openssl rand -base64 32)
echo "BlowFish Value: ${randomBlowfishSecret}"
replace_pma_blowfish="\$cfg['blowfish_secret'] = '${randomBlowfishSecret}'; \/* YOU MUST FILL IN THIS FOR COOKIE AUTH! *\/"
sed -i "s/\$cfg\[.blowfish_secret.\]\s*=.*/${replace_pma_blowfish}/" /var/www/html/phpMyAdmin/config.inc.php

它可以工作,但是如果blowfish键包含这个字符“/”,我会得到像这样的sed错误:

root@test:./test
BlowFish Value: omaRJZpTeWZPQU+dqDc7UlrXZnL6j8i0wSE/3kTnjLU=
sed: -e expression #1, char 99: unknown option to `s'

有没有办法生成 openssl 32 字符并且没​​有此字符“/”,或者我们如何允许 openssl 中的某些字符集(例如这组字符):

!#%+23456789:=?@ABCDEFGHJKLMNPRS

为了防止脚本中出现错误,我想避免使用某些字符,例如“/”“$”等。我知道转义斜杠是有效的,但我不想使用这个字符,因为它会与其他代码产生错误,并且我不想更改其他代码,例如 roundcube 不接受字符':' 和 '@',我认为这个字符 '/' 与其他代码也会有问题。所以我不希望 openssl 生成这个字符 '/'

要求:

  1. 允许使用一些特殊字符,例如“[' ']' '?'并避免使用一些字符,例如 '/' '$'
  2. 密码长度为32

最佳答案

-base64 切换到 -hex 以避免生成密码中的 /

关于bash - 如何生成不带某些字符或允许某些字符集的 openssl 河豚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65528031/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com