::base64conv.cmd::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal enabledelayedexpansion
set code=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
set /A B1=10,B2=0x7f,B3=255
echo %B1% %B2% %B3%
:: Byte-triplet to base64-quadruple First echo the ASCII characters to be encoded
set /A Q1=(%B1% "&" 252) ">>" 2
set /A Q2=((%B1% "&" 3) "<<" 4) + ((%B2% "&" 240) ">>" 4)
set /A Q3=((%B2% "&" 15) "<<" 2) + ((%B3% "&" 192) ">>" 6)
set /A Q4=(%B3% "&" 63)
::
echo %Q1% %Q2% %Q3% %Q4% Second echo completed encoding
echo !code:~%Q1%,1! !code:~%Q2%,1! !code:~%Q3%,1! !code:~%Q4%,1!
:: Base64-quadruple to byte-triplet Third echo The Base64 characters are out!
:: yes, I know, to work a loop to find the pos in %code% should be here.
set /A B1=(%Q1% "<<" 2) + ((%Q2% "&" 48) ">>" 4)
set /A B2=((%Q2% "&" 15) "<<" 4) + ((%Q3% "&" 60) ">>" 2)
set /A B3=((%Q3% "&" 3) "<<" 6) + %Q4%
::
echo %B1% %B2% %B3% Fourth echo decoded to the original character
::base64conv.cmd::::::::::::::::::::::::::::::::::::::::::::::::::::::::
It can be seen that the bit operations of set /a are powerful! I don't understand the above code at all. For details, see
http://groups.google.com/group/alt.msdos.batch.nt/browse_thread/thread/cfe3dbf991d68187/b03cb66dd08c2719?lnk=gst&q=base64&rnum=1#b03cb66dd08c2719
Moderators, experts, and lurkers here, come out and think about how to implement BASE64 encoding/decoding with pure batch processing?
The theoretical research on the Base64 algorithm is very useful. A simple example is: batch processing encryption, binary files embedded in bat, processing EMail, etc.
[ Last edited by electronixtar on 2006-11-15 at 01:25 AM ]
C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"

DigestI