Results 1 to 2 of 2

Thread: Help with base64 decoding!

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Help with base64 decoding!

    Hi!

    Im currently working on a client that get information from a backend server (Linux/java). The server and client send smime messages between eachother, and for some reason, when the server sends a message containing a binary file, this file becomes bigger when it is decoded on the server.

    The message looks something like this
    Code:
    Message-ID: <846550737.170.1360675318640.JavaMail.abc@bretssa>
    MIME-Version: 1.0
    Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-1; 
    	boundary="----=_Part_169_743690211.1360675318603"
    X-Unencoded-Content-Length: 5836
    
    ------=_Part_169_743690211.1360675318603
    Content-Type: application/pkcs-12
    Content-Transfer-Encoding: base64
    
    MIINFgIBAzCCDNAGCSqGSIb3DQEHAaCCDMEEggy9MIIMuTCCBW4GCSqGSIb3DQEHAaCCBV8EggVb
    MIIFVzCCBVMGCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBQnLESNpCKgUS9p
    1AMuYcNbwHThOgICBAAEggTIVm3CqW3KltldgI0PCef0SsoHfUtQTr98LxlkwE3pP8ESplU4/C7m
    hpqM/e1LaQlbzLwVGb/86NkZ3kSj+HNC0O+0Vy/h7MFRrosFZNSlJIJom8y6elTo3CPokT57vPIf
    OCe0oPwsNcGUJiywNh888OlQNiIiUmXuL6qUpKyqmvBKt3qSF/7nXyxG8sJXsMUnc86aHguWLgWT
    ------=_Part_169_743690211.1360675318603
    Content-Type: application/pkcs7-signature; name=smime.p7s; smime-type=signed-data
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename="smime.p7s"
    Content-Description: S/MIME Cryptographic Signature
    
    MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAMYICGTCCAhUC
    AQEwgZIwgYoxCzAJBgNVBAYTAlNFMTUwMwYDVQQKDCxXaXJlbGVzcyBJbmRlcGVuZGVudCBQcm92
    ------=_Part_169_743690211.1360675318603--
    They have checked on the server and the binary file is about 2,5 kb Before they encode it to base64 and send it. And when I read the smime message, and use the Convert.FromBase64 and write the file as a byte Array to disk, it is about 3,5 kb in size! Where does the extra 1 kb come from?

    I even did a test and used copy/paste and took only the base64 chunk that represent the file and pasted it into a text document, and did a Convert.FromBase64 and got the exact same file around 3,5 kb. This to rule out any bugs in the smime Component we use to parse mime messages.

    What is wrong here? What have we forgotten? Are there additional characters that get embedded somehow, line breaks, CR etc? Or do we use different base64 on java server and .net client?

    any ideas?
    /H

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Help with base64 decoding!

    It may be that the machines are using different character sets. Newlines might account for some of it.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width