anyone have the sourcecode the a base64 converter? or can explain the algorithm?
Posted on 2001-03-02 18:16:00 by Zynaps
nevermind i found it
Posted on 2001-03-02 21:28:00 by Zynaps
Can you share the BASE64 code you found with me? I've been trying to develop it myself with little success. I have UUDecoding source if you need it. Xtreme
Posted on 2001-03-02 22:01:00 by xtreme
yes, i'll share it once i have implemented it. i'll do it when i wake up tomorrow, saturday. (should be around 14:00 CET, seeing as it is 05:00 now and im not sleeping yet)
Posted on 2001-03-02 22:50:00 by Zynaps
to Zynaps n xtreme... could you guys also share your sources with me? elf+boi
Posted on 2001-03-02 23:33:00 by elf+boi
Zynaps / elf+boi, This is really cool to finally get some B64 and UUDecoding sources working together. My question is, how do I determine, programatically, if the file being processed is B64 or UUD? Do I just look for the "BEGIN" and if its not found assume its B64? Xtreme
Posted on 2001-03-03 00:59:00 by xtreme
here it is, tested and everything.

	alphabet	db "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
base64encode PROC source:DWORD, destination:DWORD, sourcelen:DWORD
	push edi
	push esi
	push ebx
	mov  esi, source
	mov  edi, destination
	.IF sourcelen == 1
		mov al, byte ptr 
		and eax, 0FFh
		mov ecx, 2					;bytes to output = 2
		mov edx, 03D3Dh					;padding = 2 byte
		inc esi						;source ptr + 1
		dec sourcelen					;length - 1
	.ELSEIF sourcelen == 2
		mov ax, word ptr 
		and eax, 0FFFFh
		mov ecx, 3					;bytes to output = 3
		mov edx, 03Dh					;padding = 1 byte
		add esi, 2					;source ptr + 2
		sub sourcelen, 2				;length - 2
		mov eax, dword ptr 
		and eax, 0FFFFFFh
		mov ecx, 4					;bytes to output = 4
		xor edx, edx					;padding = 0 byte
		add esi, 3					;source ptr + 3
		sub sourcelen, 3				;length - 3 

	xchg al,ah						; flip eax completely
	rol  eax, 16						; can this be done faster
	xchg al,ah						; ??

	push  eax
	and   eax, 0FC000000h					;get the last 6 high bits
	rol   eax, 6						;rotate them into al
	mov   al,  byte ptr 		;get encode character
	stosb							;write to destination
	pop   eax
	shl   eax, 6						;shift right 6 bits
	dec   ecx
	jnz   @B						;loop
	cmp   sourcelen, 0
	jnz   @@base64loop					;main loop
	mov   eax, edx						;add padding and null terminate
	stosd							;  "     "    "     "     "

	pop   ebx
	pop   esi
	pop   edi
base64encode ENDP
maybe one of the asm wizards on this board could optimize it? :)
Posted on 2001-03-03 11:41:00 by Zynaps
do you also need a decoder? i haven't written that yet because i don't need it. but i might do it later if i get 1 or 2 requests ;)
Posted on 2001-03-03 11:50:00 by Zynaps
Ok, i'll also write a decoder :)
Posted on 2001-03-04 09:19:00 by Zynaps

xchg al,ah                  ; flip eax completely
rol  eax, 16                ; can this be done faster
xchg al,ah                  ; ??
Sure can try this, there is a intruction designed specifly for endian swapping:

bswap eax
There u go, have a good one
Posted on 2001-03-05 02:22:00 by George
a base64 decoder? sure! if it's alright with you though... elf+boi
Posted on 2001-03-06 16:54:00 by elf+boi
already written it. gonna get them posted on the front page once i've written some example programs.
Posted on 2001-03-06 17:12:00 by Zynaps