Last active
July 22, 2022 13:03
-
-
Save krlicmuhamed/b2b7e65bf61a16330cd30cf6478e08e3 to your computer and use it in GitHub Desktop.
Decode a base64 string in FoxPro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FUNCTION DECSTR64 | |
PARAMETERS S | |
LOCAL i,j,j,k,q,ch,s2,buf,tmpc | |
tmpc = 0 | |
j = 0 | |
buf = 0 | |
s2 = '' | |
k = LEN(s) | |
FOR i = 1 TO k | |
ch = ASC(SUBSTR(s,i,1)) | |
q = IIF((ch >= 97 AND ch <=122),25+ch-96,IIF((ch >= 65 AND ch <=90),ch-65,; | |
IIF((ch >= 48 AND ch <=57),ch+4,IIF(ch = 47,63,IIF(ch=43,62,-1))))) | |
IF q < 0 THEN | |
RETURN IIF(ch = 61,s2,'') | |
ENDIF | |
buf = BITOR(BITLSHIFT(buf,6),q) | |
j = j + 6 | |
IF j >= 8 THEN | |
j = j - 8 | |
tmpc = CHR(BITAND(BITRSHIFT(buf,j),255)) | |
buf = BITAND(buf,BITLSHIFT(1,j) -1) | |
s2 = s2 + tmpc | |
ENDIF | |
ENDFOR | |
RETURN s2 | |
ENDFUNC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment