Base64 Encryption Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lauren Quantrell

    #1

    Base64 Encryption Question

    I have a spec that calls for a Base64 encrypted password to be passed
    to a web service.
    I have poked around Convert.ToBase6 4 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 xEncryptedStrin g as string

    xRawString = "MyPasswordStri ng"

    xEncryptedStrin g = SomehowConvertT oBase64(xRawStr ing)

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

    Get
    Return xEncryptedStrin g
    End Get

    Set(ByVal value As String)
    Me.passwordFiel d = xEncryptedStrin g
    End Set

    End Property

  • Michel Posseth  [MCP]

    #2
    Re: Base64 Encryption Question


    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 Quantrell" <laurenquantrel l@hotmail.comsc hreef in bericht
    news:1174169919 .873621.186700@ p15g2000hsd.goo glegroups.com.. .
    >I have a spec that calls for a Base64 encrypted password to be passed
    to a web service.
    I have poked around Convert.ToBase6 4 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 xEncryptedStrin g as string
    >
    xRawString = "MyPasswordStri ng"
    >
    xEncryptedStrin g = SomehowConvertT oBase64(xRawStr ing)
    >
    '******** end totally FOO code: ************
    >
    Get
    Return xEncryptedStrin g
    End Get
    >
    Set(ByVal value As String)
    Me.passwordFiel d = xEncryptedStrin g
    End Set
    >
    End Property
    >

    Comment

    • =?ISO-8859-1?Q?G=F6ran_Andersson?=

      #3
      Re: Base64 Encryption Question

      Lauren Quantrell wrote:
      I have a spec that calls for a Base64 encrypted password to be passed
      to a web service.
      I have poked around Convert.ToBase6 4 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 xEncryptedStrin g as string
      >
      xRawString = "MyPasswordStri ng"
      >
      xEncryptedStrin g = SomehowConvertT oBase64(xRawStr ing)
      >
      '******** end totally FOO code: ************
      >
      Get
      Return xEncryptedStrin g
      End Get
      >
      Set(ByVal value As String)
      Me.passwordFiel d = xEncryptedStrin g
      End Set
      >
      End Property
      >
      As Michel pointed out, Base64 is not encryption. It's just encoding.

      The Convert.ToBase6 4String 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.ToBase6 4String(Encodin g.UTF8.GetBytes (password))

      --
      Göran Andersson
      _____
      Göran Anderssons privata hemsida.

      Comment

      • Lauren Quantrell

        #4
        Re: Base64 Encryption Question

        On Mar 18, 10:35 am, Göran Andersson <g...@guffa.com wrote:
        Lauren Quantrell wrote:
        I have a spec that calls for a Base64 encrypted password to be passed
        to a web service.
        I have poked around Convert.ToBase6 4 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 xEncryptedStrin g as string
        >
        xRawString = "MyPasswordStri ng"
        >
        xEncryptedStrin g = SomehowConvertT oBase64(xRawStr ing)
        >
        '******** end totally FOO code: ************
        >
        Get
        Return xEncryptedStrin g
        End Get
        >
        Set(ByVal value As String)
        Me.passwordFiel d = xEncryptedStrin g
        End Set
        >
        End Property
        >
        As Michel pointed out, Base64 is not encryption. It's just encoding.
        >
        The Convert.ToBase6 4String 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.ToBase6 4String(Encodin g.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

        Comment

        Working...