加密代码:

#!/bin/bash

string="Hello, World!"  # 待加密的字符串

# 将字符串转换为base64编码
encoded_string=$(echo -n $string | base64)

echo "原始字符串: $string"
echo "加密后字符串: $encoded_string"

解密代码:

#!/bin/bash

encoded_string="SGVsbG8sIFdvcmxkIQ=="  # 待解密的字符串

# 将base64编码的字符串解码
decoded_string=$(echo -n $encoded_string | base64 -d)

echo "加密后字符串: $encoded_string"
echo "原始字符串: $decoded_string"

运行结果:

原始字符串: Hello, World!
加密后字符串: SGVsbG8sIFdvcmxkIQ==
加密后字符串: SGVsbG8sIFdvcmxkIQ==
原始字符串: Hello, World!
``
shell脚本字符串base64加解密

原文地址: https://www.cveoy.top/t/topic/fr6N 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录