Restored from previous forum. Originally posted by Num3.
Well PB encodes to base64...
And what about decoding a b64 file/string ???
--
Kind Regards
Rui Carvalho
Current PB Projects:
[Construdata 2003 - 30%]
[Step by Step - 50%]
BASE64 DECODE
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
To clear things up: this is not my code!
Found this some time ago in the german forum, don't recall who did this.
(Shame on me, forgot to write it down...)
The only change I did, was to change the input data from a pointer to a string - now it's equal to the encoding command in pb.
Have a nice day...
Franco
To clear things up: this is not my code!
Found this some time ago in the german forum, don't recall who did this.
(Shame on me, forgot to write it down...)
The only change I did, was to change the input data from a pointer to a string - now it's equal to the encoding command in pb.
Code: Select all
Procedure Base64Decoder(b64in$, b64len.l ,*b64out, b64max.l)
*b64in.l = @b64in$ ; 0
If b64num = 65
b64pad +1
EndIf
b64bin$ +Right("000000" + Bin(b64num-1),6) ;24 Bit code
Else
b64err = 1
b64xln = b64tln +1
EndIf
Next b64xb
For b64xu = 0 To 2-b64pad
b64bit$ = Mid(b64bin$,1+b64xu*8,8) + "|"
b64num = FindString(b64asc$,b64bit$,0) /9 ;ASC Code 8 Bit Binary
PokeS(*b64out+b64buf,Chr(b64Num))
b64buf +1
If b64buf >b64max
b64err = 1
b64xln = b64tln +1
EndIf
Next b64xu
Next b64xln
If b64err = 1
RtlFillMemory_(*b64out,b64max,0)
b64buf = -1
EndIf
ProcedureReturn b64buf
EndProcedure
Franco
Code: Select all
8)b64asc$ = b64asc$ + Right("0000000" + Bin(b64x),8) + "|"
Code: Select all
For b64x = 0 To 255
b64asc$ = b64asc$ + Right("0000000" + Bin(b64x),8) + "|" ;ASC Binary Code
Next b64xb64bit$ = Mid(b64bin$,1+b64xu*8,8) + "|"
Code: Select all
For b64xu = 0 To 2-b64pad
b64bit$ = Mid(b64bin$,1+b64xu*8,8) + "|"
b64num = FindString(b64asc$,b64bit$,0) /9 ;ASC Code 8 Bit Binary
PokeS(*b64out+b64buf,Chr(b64Num))
b64buf +1
If b64buf >b64max
b64err = 1
b64xln = b64tln +1
EndIf
Next b64xupeace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]

