Base64 algorythm?
Author Message
Base64 algorythm?

Does anyone know where I can find the algorythm for base64
encoding/decoding?

Thanks for any help.

Don Krouse

Everett, WA, USA

Sun, 19 Jul 1998 03:00:00 GMT
Base64 algorythm?

Quote:

> Does anyone know where I can find the algorythm for base64
> encoding/decoding?

That would waste two bits of "bandwidth" from every byte - unless you
collapsed your data across byte boundaries.
Here goes:

MaxDigit = how ever many digits you want to allow (for example the
internal storage for an integer is a two digit base 256 number, Longs are
stored internally as four digit base 256 numbers)
Number = the number you want to convert (presumably it is decimal)
Base = 64

Function ConvertToBase\$(Base, ByVal Number)
Dim NewNum\$, Counter, DigitVal
CONST MaxDigit = 10 '(whatever you want, however keep overflows in mind)
NewNum\$ = String\$(MaxDigit, 0)
For Z = MaxDigit - 1 to 0 Step -1
Counter = 0
DigitVal = Base^Z
Do While Number => DigitVal
Number = Number - DigitVal
Counter = Counter + 1
Loop
Mid\$(NewNum\$, MaxDigit - Z, 1) = Chr\$(Counter)
Next
' Number should = 0 at this point
' NewNum\$ now contains your base x number
ConvertToBase\$ = NewNum\$
End Function

This routine uses the ASCII codes to represent the ordinal values 0 - 255.

-chris

Mon, 20 Jul 1998 03:00:00 GMT
Base64 algorythm?

Quote:

> > Does anyone know where I can find the algorythm for base64
> > encoding/decoding?

> That would waste two bits of "bandwidth" from every byte - unless you
> collapsed your data across byte boundaries.
> Here goes:

He means MIME, not numbers using the base 64 system.

_  _____  _   _

| || (_) || `\| |
| ||  _  || , ` | If they give you lined paper, write the other way!
| || | | || |`\ |
(_)(_) (_)(_) (_) http://www.sn.no/~balchen/igloo/

Mon, 20 Jul 1998 03:00:00 GMT
Base64 algorythm?
Quote:

>> Does anyone know where I can find the algorythm for base64
>> encoding/decoding?

>That would waste two bits of "bandwidth" from every byte - unless you
>collapsed your data across byte boundaries.
>Here goes:

[code & algoirthm snipped]

I'm wondering if maybe Don wasn't looking for the MIME Base64
file encoding algorithm (MIME's version of uuencode/decode) ???
MIME is covered in RFC-1521, available in at "ds.internic.net" in
"/rfc/rfc1521.txt".  Other info is available by sending mail to

message is all that's required ...
Then there's the "comp.mail.mime" newsgroup ...

Good luck.

--
+--------------------------------+---------------------------+

| "Don't call us Seagate (yet)"  |     "WTB : clever sig"    |
+--------------------------------+---------------------------+

Mon, 20 Jul 1998 03:00:00 GMT
Base64 algorythm?

Quote:

> Does anyone know where I can find the algorythm for base64
> encoding/decoding?
> That would waste two bits of "bandwidth" from every byte - unless you
> collapsed your data across byte boundaries.

For starters try:
http://www.cis.ohio-state.edu/hypertext/faq/usenet/mail/mime-faq/top....

Peter Mikalajunas

http://www.xnet.com/~kd9fb

Wed, 22 Jul 1998 03:00:00 GMT
Base64 algorythm?

Quote:

> Path:
> Does anyone know where I can find the algorythm for base64
> encoding/decoding?

> Thanks for any help.

> Don Krouse

> Everett, WA, USA

I believe that it is documented in RFC1521 under the title QUOTE 64. you can