Base64 Encryption Question

  • Thread starter Thread starter Lauren Quantrell
  • Start date Start date
L

Lauren Quantrell

I have a spec that calls for a Base64 encrypted password to be passed
to a web service.
I have poked around Convert.ToBase64 but am at a total loss on how to
do this.
Made more complicated is that the password is part of a complex data
type class.

What I am trying to do is something functions like this below
(replacing FOO code with something that works) Any help is greatly
appreciated:

Public Property password() As String

'******** start totally FOO code: ************

Dim xRawString as string
Dim xEncryptedString as string

xRawString = "MyPasswordString"

xEncryptedString = SomehowConvertToBase64(xRawString)

'******** end totally FOO code: ************

Get
Return xEncryptedString
End Get

Set(ByVal value As String)
Me.passwordField = xEncryptedString
End Set

End Property
 
Base64 encoding is not an encryption method , it is just a way of converting
binary data into text ( e-mail progs use it for instance to onclude images
in a message )
the encode and decode base 64 classes can be found in the text namespace
and is pretty straigforward in use


HTH

Michel Posseth
 
Lauren said:
I have a spec that calls for a Base64 encrypted password to be passed
to a web service.
I have poked around Convert.ToBase64 but am at a total loss on how to
do this.
Made more complicated is that the password is part of a complex data
type class.

What I am trying to do is something functions like this below
(replacing FOO code with something that works) Any help is greatly
appreciated:

Public Property password() As String

'******** start totally FOO code: ************

Dim xRawString as string
Dim xEncryptedString as string

xRawString = "MyPasswordString"

xEncryptedString = SomehowConvertToBase64(xRawString)

'******** end totally FOO code: ************

Get
Return xEncryptedString
End Get

Set(ByVal value As String)
Me.passwordField = xEncryptedString
End Set

End Property

As Michel pointed out, Base64 is not encryption. It's just encoding.

The Convert.ToBase64String method takes a byte array, so if you have a
string as input, you have to first encode it into binary data.

What encoding does the web service expect? ASCII? UTF-8? Latin1?

Here is an example using UTF-8 encoding:

base64Encoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(password))
 
As Michel pointed out, Base64 is not encryption. It's just encoding.

The Convert.ToBase64String method takes a byte array, so if you have a
string as input, you have to first encode it into binary data.

What encoding does the web service expect? ASCII? UTF-8? Latin1?

Here is an example using UTF-8 encoding:

base64Encoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(password))

--
Göran Andersson
_____http://www.guffa.com- Hide quoted text -

- Show quoted text -

Goran,
Thanks much. Now I understand this and your line of code made it work
for me.
lq
 
Back
Top