帮写个批处理Base64加密

来源:百度知道 编辑:UC知道 时间:2024/06/14 19:21:43
Base64加密要P处理的

@echo off
setlocal
echo 请输入要转换的字符串(可以有汉字):
set/p input=
set str=%input%

::利用 fc/b 获取16进制代码{modify zh159}
>temp.txt set/p=%input%<nul
call :test temp.txt
::利用fsutil创建一个一样大小的文件
fsutil file createnew tmp.txt %size% >nul 2>nul

for /f "tokens=3" %%i in ('fc/b tmp.txt temp.txt^|findstr "^0000"') do call set "hex=%%hex%%%%i"
del temp.txt
del tmp.txt

:str2hex
set "base64=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
setlocal enabledelayedexpansion
:hex2base64
if not defined hex goto :print
for /l %%a in (1,1,3) do (
set/a "n=2*(%%a-1)"
call set x=%%hex:~!n!,2%%
set "c%%a=0x!x!"
if "!x!" equ "" set c%%a=0
)
set hex=%hex:~6%
set/a ec1=%c1%">>"2
set/a ec2=%c1%"<<