1. At last ! A euphoria solution to those irritating attachments.
- Posted by Daniel Johnson <Lmailles at AOL.COM> Sep 26, 1998
- 564 views
- Last edited Sep 27, 1998
Here is a special message, for those of you who, like me, are unable to decode Base64 files. Below is a fully-functional programme which does the nuts and bolts of Base64 decoding. All you have to do is remove the header lines. If you find it useful, please vote for it, and I will be encouraged to get on with other projects, like my much publicised 3d toolkit. NB, if the listserv is having an =3D day ie messing up all our programmes with lots of =FA and =this and =that then you will also have to correct this manually. This may even be the case with my prog, in which case you better get it off Irv or Rob. I have been up all night working out the Base64 lookup tables so I hope it is useful. The Lord bless and keep you, Daniel ----------------------Begin unbase63.ex-------------------------------- --Prog by D Johnson to decode Base64. You should manually strip out the --headers so that the file starts with the first character. constant lookup= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 , function check_valid(sequence data) integer ret ret=1 for a=1 to length(data) do if not find(data[a], lookup) and not data[a]='=' then ret=0 end if end for return ret and remainder(length(data),4)=0 end function function read_file(integer fn) --Reads in everythin from an open file, ignoring CR/LFs object this sequence ret ret={} this=gets(fn) while sequence(this) do if this[length(this)]='\n' then ret = ret & this[1..length(this)-1] else ret = ret & this end if this=gets(fn) end while return ret end function function unbase64(sequence data) --Supposedly decodes Base64 data. Data should be checked first using check_valid() sequence undecoded, temp, tempdata integer const undecoded={} data = data + 1 if find('=',data[length(data)-3..length(data)]) then const= -4 else const=0 end if for a=1 to length(data)+const by 4 do tempdata={} for b=a to a+3 do tempdata = tempdata & lookup[data[b]] end for temp={0,0,0} temp[1] = tempdata[1]*4 + and_bits(tempdata[2],48)/16 temp[2] = and_bits(tempdata[2],15)*16 + and_bits(tempdata[3],60)/4 temp[3] = and_bits(tempdata[3],3)*64 + tempdata[4] undecoded = undecoded & temp end for --Special code for last four bytes if const= -4 then tempdata = lookup[data[length(data)-3]] & lookup[data[length(data)-2]] temp={} temp = temp & tempdata[1]*4 + and_bits(tempdata[2],48)/16 const = find('=',data[length(data)-3..length(data)]) --find the '=' if const = 4 then --ie if there are two bytes to extract tempdata = tempdata & lookup[data[length(data)-1]] temp = temp & and_bits(tempdata[2],15)*16 + and_bits(tempdata[3],60)/4 end if undecoded = undecoded & temp end if return undecoded end function procedure main() sequence filename, data integer fn puts(1,"\nEnter the file to decode : ") filename=gets(0) filename = filename[1..length(filename)-1] fn = open(filename,"r") if fn > 1 then data=read_file(fn) close(fn) if check_valid(data) then puts(1,"\nDecoding...\n") fn = open(filename[1..find('.',filename)]&"lmt","wb") if fn > 2 then puts(fn,unbase64(data)) puts(1,"File saved, with .lmt extension. Success !\n") else puts(1,"Could not open destination file\n") end if else puts(1,"\nNot a valid Base64 file\n") ? length(data) end if else puts(1,"\nCould not open "&filename&"\n") end if end procedure main()
2. Re: At last ! A euphoria solution to those irritating attachments.
- Posted by Matt Z Nunyabidness <matt1421 at JUNO.COM> Sep 26, 1998
- 563 views
- Last edited Sep 27, 1998
what's Base64? Is it like decoding uuencode or something? GREAT!!!!!!!!!!!!!! ------------------------------------- When it comes to programming languages, Euphoria is a cut above - matt1278 at juno.com and matt1421 at juno.com(and soon to be irisnmatt at prodigy.net. Then again, maybe not) Euphoria programmer ___________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]
3. Re: At last ! A euphoria solution to those irritating attachments.
- Posted by Matt Z Nunyabidness <matt1421 at JUNO.COM> Oct 04, 1998
- 590 views
i think it's broken. first of all, the variables had to be declare out side of the functions and procedures. Second, and_bits() doesn't exist. ___________________________ When it comes to programming languages, Euphoria is a cut above - matt1278 at juno.com and matt1421 at juno.com Euphoria programmer Webbers: <A HREF="mailto:prezsoft at juno.com">prezsoft at juno.com</A>, president of SoftCo. Fluent in HTML, yet no internet. Knows DEBUG ASM. ___________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]
4. Re: At last ! A euphoria solution to those irritating attachments.
- Posted by Hawke <mdeland at NWINFO.NET> Oct 04, 1998
- 559 views
Matt Z Nunyabidness wrote: >Second, and_bits() doesn't exist. uhhhhh.... check library.doc... it most assuredly "exists".
5. Re: At last ! A euphoria solution to those irritating attachments.
- Posted by Matt Z Nunyabidness <matt1421 at JUNO.COM> Oct 04, 1998
- 543 views
is that in eu 2.0 or something, because i have euphoria 1.4a ___________________________ When it comes to programming languages, Euphoria is a cut above - matt1278 at juno.com and matt1421 at juno.com Euphoria programmer Webbers: <A HREF="mailto:prezsoft at juno.com">prezsoft at juno.com</A>, president of SoftCo. Fluent in HTML, yet no internet. Knows DEBUG ASM. ___________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]