Linux下的链条式密码生成Shell脚本

2019年12月10日

原创内容,转载请注明出处:https://www.myzhenai.com.cn/post/3054.html

关键词:Linux密码生成 密码生成脚本 密码自动生成

Linux下生成链条式密码钥匙的脚本:https://www.myzhenai.com.cn/post/2172.html

这个脚本是在上面的脚本基础上更新的,这个脚本生成的密码类似于一些大型软件注册码或激活码,分几个段的字符串组成的一组密码数据,由大小写与特殊字符打乱顺序并加密生成的。可以做为平时的一些服务器密码或重要的平台的注册密码。

使用方法:

将以下代码复制并保存为Password.sh脚本文件,然后在Linux终端下运行以下命令即可

bash Password.sh -r
#-r 是自动生成参数
bash Password.sh -c https://jiayu.mybabya.com/
#-c 是加密指定内容生成
bash Password.sh -h
#帮助文档

 

# !/bin/bash
###############################################################################################################################################################################################
#
# This is to get the character channeling encryption scripting tool
# Autor: RucLinux
# Web: https://www.myzhenai.com.cn/ https://www.myzhenai.com/ https://jiayu.mybabya.com/ 
#
###############################################################################################################################################################################################
random() {
  index=0
  str=""
 # t=`grep '((?=[\x21-\x7e]+)[^A-Za-z0-9])'`
  for i in {a..z}; do arr[index]=$i; index=`expr ${index} + 1`; done
  for i in {A..Z}; do arr[index]=$i; index=`expr ${index} + 1`; done
  for i in {$t}; do arr[index]=$i; index=`expr ${index} + 1`; done
  for i in {0..9}; do arr[index]=$i; index=`expr ${index} + 1`; done
  for i in {1..42}; do str="$str${arr[$RANDOM%$index]}"; done
  #echo $str
s=`echo $str |cut -c1-42`
echo ${s:0:6}-${s:12:6}-${s:18:6}-${s:24:6}-${s:30:6}-${s:36:6}
}
########################################################################################################### 
create() (
ip=`ifconfig | awk -F'[ ]+|:' '/inet addr/{if($4!~/^192.168|^172.16|^10|^127|^0/) print $4}'`
name="$two"
a=`echo "${name}" |wc -L`
if [ $a -lt 6 ];then
site=$name.$ip
else
site=$name
fi
md=`echo $site |base64 -i`
b=`echo $md |wc -L`
if [ $b -lt 36 ];then
stin=`echo $md | md5sum |base64 -i`
else
stin=$md
fi
s=`echo $stin |cut -c1-42`
echo ${s:0:6}-${s:12:6}-${s:18:6}-${s:24:6}-${s:30:6}-${s:36:6}
)
###########################################################################################################

###########################################################################################################

#This is the documentation help
###########################################################################################################
Open_help() (
echo 'Chain password automatic generation tool'
echo '-r This is a randomly generated key option'
echo '-c This is the password generation key option'
echo '-h This is the documentation'
)
###########################################################################################################
par=$1
two=$2
[ -z $1 ] && action='-h'
case "$par" in
    -h)
    Open_help
    ;;
    -r)
    random
    ;;
    -c)
    create $1 $two
    ;;
    *)
    echo "Arguments error! [${par}]"
    echo "Usage: `basename $0` {-h|-r|-c}"
    ;;
esac

 


sicnature ---------------------------------------------------------------------
Your current IP address is: 54.87.17.177
Your IP address location: 美国弗吉尼亚阿什本
Your IP address country and region: 美国 美国
Your current browser is:
Your current system is:
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source https://www.myzhenai.com.cn/post/3054.html

1 评论

  • JiaYu Blog 2021年03月14日在1:11 上午

    Php

    <?php
    $str = '科技有限公司';
    $encode = base64_encode($str);
    echo $encode.'’;
    echo base64_decode($encode);
    ?>

    php函数:substr_replace(string,insert_string, $start, 0)
    参数说明:

    1. $string: 被插入的字符串
    2. $insert_string: 待插入的字符串
    3. $start: 插入的位置

    例如:

    $string = “abc”;
    $insert_string = ‘123″;
    $start = 1;
    $newstring = substr_replace($string, $insert_string, $start, 0);
    echo $newstring; /* $newstring 为 a123bc*/

回复 JiaYu Blog 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注