Visual Basic/VB >> Base64

by Mike D Sutton » Thu, 24 Jul 2003 01:29:19 GMT

> Does anyone have good Base64 functions?
> Functions does not mean DLLs or OCXs

Here's a function that converts an API LARGE_INTEGER type (64-bit) to a VB
Decimal for working with internally:
http://groups.google.co.uk/groups?selm=OhECh5%23IDHA.2220%40TK2MSFTNGP10.phx.gbl
If you're open to API calls, then you could also try the RtlLargeInteger*()
calls which perform various mathematics functions on large integers.
If this wasn't what you wanted, then try posting a little more about what
you really want, it's a somewhat unspecific question..
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: XXXX@XXXXX.COM
WWW: Http://www.mvps.org/EDais/




Visual Basic/VB >> Base64

by Tony Proctor » Thu, 24 Jul 2003 02:21:28 GMT


I think this is exactly what you need Jason...

http://www.paradoxes.info/code/base64.html

Tony








Visual Basic/VB >> Base64

by me » Thu, 24 Jul 2003 02:31:28 GMT

try www.vbip.com
hth
Guy
??"Jason Tik" < XXXX@XXXXX.COM >
>> Does anyone have good Base64 functions? >> >> Functions does not mean DLLs or OCXs >> >> Thanks in advance >> >>




Base64

by vbGansta » Thu, 24 Jul 2003 03:47:00 GMT

Private Function Base64_Encode(strSource) As String
'
Const BASE64_TABLE As String =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
'
Dim strTempLine As String
Dim j As Integer
'
For j = 1 To (Len(strSource) - Len(strSource) Mod 3) Step 3
'
strTempLine = strTempLine + Mid(BASE64_TABLE, _
(Asc(Mid(strSource, j, 1)) \ 4) + 1, 1)
'
strTempLine = strTempLine + Mid(BASE64_TABLE, _
((Asc(Mid(strSource, j, 1)) Mod 4) * 16 _
+ Asc(Mid(strSource, j + 1, 1)) \ 16) + 1, 1)
'
strTempLine = strTempLine + Mid(BASE64_TABLE, _
((Asc(Mid(strSource, j + 1, 1)) Mod 16) * 4 _
+ Asc(Mid(strSource, j + 2, 1)) \ 64) + 1, 1)
'
strTempLine = strTempLine + Mid(BASE64_TABLE, _
(Asc(Mid(strSource, j + 2, 1)) Mod 64) + 1, 1)
'
Next j
'
If Not (Len(strSource) Mod 3) = 0 Then
'
If (Len(strSource) Mod 3) = 2 Then
'
strTempLine = strTempLine + Mid(BASE64_TABLE, _
(Asc(Mid(strSource, j, 1)) \ 4) + 1, 1)
'
strTempLine = strTempLine + Mid(BASE64_TABLE, _
(Asc(Mid(strSource, j, 1)) Mod 4) * 16 _
+ Asc(Mid(strSource, j + 1, 1)) \ 16 + 1, 1)
'
strTempLine = strTempLine + Mid(BASE64_TABLE, _
(Asc(Mid(strSource, j + 1, 1)) Mod 16) * 4 + 1, 1)
'
strTempLine = strTempLine & "="
'
ElseIf (Len(strSource) Mod 3) = 1 Then
'
strTempLine = strTempLine + Mid(BASE64_TABLE, _
Asc(Mid(strSource, j, 1)) \ 4 + 1, 1)
'
strTempLine = strTempLine + Mid(BASE64_TABLE, _
(Asc(Mid(strSource, j, 1)) Mod 4) * 16 + 1, 1)
'
strTempLine = strTempLine & "=="
'
End If
'
End If
'
Base64_Encode = strTempLine
'
End Function






Base64

by Ben Taylor » Thu, 24 Jul 2003 04:08:13 GMT

consider using C#







Base64

by Jason » Fri, 03 Oct 2003 19:47:12 GMT

Where can I get source code for Byte To Base64 and Base64 To Byte?\

I don't want a library. A module would be ok.




Base64

by Matt Williamson » Sat, 04 Oct 2003 00:54:25 GMT

Jason-

I don't have my library of code snips here, but I remember find the base64
algorithm that I use from doing a google search for "Base64 vb" and
filtering through the answers.

I know there is also a base64 routine over at www.vbip.com

HTH

Matt







Base64

by Frampton Firesword » Sat, 04 Oct 2003 04:43:55 GMT

I had a question on base 64 answered very well by someone in
www.developersdex.com, quite a while back though. You might be able to do a
search on either that site or the alleged 'google archives' for 'BITS - bet
no-one can answer this!'.

Hope this helps







Similar Threads

1. Convertion to base64 results in malformed data.

I tried to write a little commandline tool that converts a file to a base64
datastream.
The application that needs to work with these base64 files (MS Word 2003 in
XML) doesn't accept the resultfiles of my tool though.
When I compare my resultfile with a file that has been generated by Word I
can see that only the first 3 characters of the stream are different.
No matter what file I convert, my first 3 chars are always " 9/" while Word
always writes "/9j". All other chars are identical.
Is this somekind of header? Do I use an incorrect datatype?

Below is a code snippet which I use to convert the data. (I added the '
before each line to work around a paranoid virusscanner)

'Dim fsi As New System.IO.FileStream(file, IO.FileMode.Open)
'Dim fso As System.IO.FileStream
'Try
'    fso = New System.IO.FileStream(fileNameOut, IO.FileMode.CreateNew)
'Catch e As Exception
'    fso = New System.IO.FileStream(fileNameOut, IO.FileMode.Truncate)
'End Try
'Dim br As New System.IO.BinaryReader(fsi)
'Dim bw As New System.IO.BinaryWriter(fso)
'Dim targetString As String

'targetString = Convert.ToBase64String(br.ReadBytes(CInt(fi.Length())))

'bw.Write(targetString)
'bw.Close()
'br.Close()
'fso.Close()
'fsi.Close()


Thanks in advance,

Romain


2. Convert base64 string to file - VB.Net

3. Encode a string using Base64

Hello friends

I'm creating one application that will send content to another app using 
HTTP connection. To authenticate my connection, I need to send a string with 
the username and password encoded using Base64.
 
Dim username as String
Dim pass as String
Dim info_user as String
info_user = username + ":" + pass

and I need to encode info_user String using Base64. Can anyone help me how 
can I do this, because I'm not sure how to do this.

Thanks for Help

Bruno

4. Base64 '=' padding character Problem - VB.Net

5. MailAttachment Encoding Base64 vs. 7 bit

We have an application that uses CDO to email large quantities of data
as email attachments. We are migrating to a .Net application that does
the same using the System.Web.Mail (SMTP) functionality (as you may
have heard, CDO is not supported by .Net)

This migration has been impacting our customers. Evidently, every
attachment sent by the CDO (MAPI) application is Base64 encoded. The
.Net application, however, emails the attachments encoded either as
plain text (7 bit) or Base64, based on the data type. Is there some
Exchange server setting that will force the SMTP email message
attachments to also be Base64 encoded?

6. Convert Excel file to base64 - VB.Net

7. Base64 encoding using XMLTextWriter

Hello VB.NET XML Gurus,

I wanted to know how one can have Base64 XML encoding using XMLTextWriter.
By default it creates UTF16. I have read that one can use the contructor of
XMLTextWriter. But I see that it has only following encodings :-
1. ASCII
2. BigEndianUnicode
3. Unicode
4. UTF7
5. UTF8
6. UTF16

Thanks for your time,
Johns.


8. Base64 Encryption Question - VB.Net