encoding decoding Base64

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

encoding decoding Base64

Maarten Mostert

Hi,

 

I have the impression to miss something simple.

 

I want to encode and decode a ByteArray into and from a Base64 encoded string.

 

However I don't manage to do the reverse operation.

 

#[48 238 8 17] asBase64String  gives:    'MO4IEQ=='

 

However 

'MO4IEQ==' asByteArrayEncoding: 'Base64'. gives:     #[84 85 56 48 83 85 86 82 80 84 48 61]

 

What do I do wrong ?

 

Regards,

 

 

Maarten MOSTERT

 

 

28 Av Alphonse Denis

83400 Hyères, France

+33 676411296 

http://stakepoint.com/

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: encoding decoding Base64

Ralf Propach
Hi Maarten,

both times you use methods to encode. Try this instead:
  ByteArray fromBase64String:  'MO4IEQ==' (gives #[48 238 8 17])


'MO4IEQ==' asByteArrayEncoding: 'Base64'.
is the same as
'MO4IEQ==' asByteArray asBase64String asByteArray.
using the same asBase64String method in both your examples.

Ralf


Am 29.07.2015 09:52, schrieb [hidden email]:

> Hi,
>
> I have the impression to miss something simple.
>
> I want to encode and decode a ByteArray into and from a Base64 encoded
> string.
>
> However I don't manage to do the reverse operation.
>
> #[48 238 8 17] asBase64String *gives: *   'MO4IEQ=='
>
> However
>
> 'MO4IEQ==' asByteArrayEncoding: 'Base64'. *gives:***    #[84 85 56 48 83
> 85 86 82 80 84 48 61]
>
> What do I do wrong ?
>
> Regards,
>
> Maarten MOSTERT
>
> 28 Av Alphonse Denis
>
> 83400 Hyères, France
>
> +33 676411296
>
> http://stakepoint.com/
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__stakepoint.com_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=oQmY7z9BeClneFUFwUmfhw&m=oJSTvMWq1l_9N1ek_TCJCbifQ-7tnf0plehdyc3Y50g&s=SCPNz_ERGSRVx3S06At5K9x9ZSd3rBVgKJrjXpYSopo&e=>
>
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: encoding decoding Base64

Maarten Mostert

Excellent  Thanks,

 

Maarten,


> "Ralf Propach" <[hidden email]> |

> Hi Maarten,


>
> both times you use methods to encode. Try this instead:
> ByteArray fromBase64String: 'MO4IEQ==' (gives #[48 238 8 17])
>
>
> 'MO4IEQ==' asByteArrayEncoding: 'Base64'.
> is the same as
> 'MO4IEQ==' asByteArray asBase64String asByteArray.
> using the same asBase64String method in both your examples.
>
> Ralf
>
>
> Am 29.07.2015 09:52, schrieb [hidden email]:
> > Hi,
> >
> > I have the impression to miss something simple.
> >
> > I want to encode and decode a ByteArray into and from a Base64 encoded
> > string.
> >
> > However I don't manage to do the reverse operation.
> >
> > #[48 238 8 17] asBase64String *gives: * 'MO4IEQ=='
> >
> > However
> >
> > 'MO4IEQ==' asByteArrayEncoding: 'Base64'. *gives:*** #[84 85 56 48 83
> > 85 86 82 80 84 48 61]
> >
> > What do I do wrong ?
> >
> > Regards,
> >
> > Maarten MOSTERT
> >
> > 28 Av Alphonse Denis
> >
> > 83400 Hyères, France
> >
> > +33 676411296
> >
> > http://stakepoint.com/
> >
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__stakepoint.com_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=oQmY7z9BeClneFUFwUmfhw&m=oJSTvMWq1l_9N1ek_TCJCbifQ-7tnf0plehdyc3Y50g&s=SCPNz_ERGSRVx3S06At5K9x9ZSd3rBVgKJrjXpYSopo&e=>
> >
> >
> >
> > _______________________________________________
> > vwnc mailing list
> > [hidden email]
> > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
> >
>
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: encoding decoding Base64

Niall Ross
Dear Maarten,
    you can also use the Base64FastCoder class if you wish (in
Protocols-Common), via class-side methods #encodeAsBase64String:,
#encodeAsBase64ByteArray: and #decodeBase64Encoded:.

This is no different from what Ralf mentioned except that it is faster,
but it does not expect or provide any email-usage-style linebreaks.

             Yours faithfully
                   Niall Ross

>Excellent  Thanks,
>
>Maarten,
>
>  
>
>>"Ralf Propach" <[hidden email]> |
>>    
>>
>
>
>
>  
>
>>Hi Maarten,
>>
>>both times you use methods to encode. Try this instead:
>>ByteArray fromBase64String: 'MO4IEQ==' (gives #[48 238 8 17])
>>
>>
>>'MO4IEQ==' asByteArrayEncoding: 'Base64'.
>>is the same as
>>'MO4IEQ==' asByteArray asBase64String asByteArray.
>>using the same asBase64String method in both your examples.
>>
>>Ralf
>>
>>
>>Am 29.07.2015 09:52, schrieb [hidden email]:
>>    
>>
>>>Hi,
>>>
>>>I have the impression to miss something simple.
>>>
>>>I want to encode and decode a ByteArray into and from a Base64 encoded
>>>string.
>>>
>>>However I don't manage to do the reverse operation.
>>>
>>>#[48 238 8 17] asBase64String *gives: * 'MO4IEQ=='
>>>
>>>However
>>>
>>>'MO4IEQ==' asByteArrayEncoding: 'Base64'. *gives:*** #[84 85 56 48 83
>>>85 86 82 80 84 48 61]
>>>
>>>What do I do wrong ?
>>>
>>>Regards,
>>>
>>>Maarten MOSTERT
>>>
>>>28 Av Alphonse Denis
>>>
>>>83400 Hyères, France
>>>
>>>+33 676411296
>>>
>>>http://stakepoint.com/
>>>
>>>      
>>>
>><https://urldefense.proofpoint.com/v2/url?u=http-3A__stakepoint.com_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=oQmY7z9BeClneFUFwUmfhw&m=oJSTvMWq1l_9N1ek_TCJCbifQ-7tnf0plehdyc3Y50g&s=SCPNz_ERGSRVx3S06At5K9x9ZSd3rBVgKJrjXpYSopo&e=>
>>    
>>
>>>
>>>_______________________________________________
>>>vwnc mailing list
>>>[hidden email]
>>>http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>>
>>>      
>>>
>>    
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>vwnc mailing list
>>[hidden email]
>>http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>    
>>



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: encoding decoding Base64

Maarten Mostert
Hello Nial,

Thanks this is cool, because now I can subclass Base64FastCoder to make the thing I actually wanted which is a Base64URL encoder / decoder as described here: https://fr.wikipedia.org/wiki/Base64

Regards,

Maarten MOSTERT

 

 

28 Av Alphonse Denis
83400 Hyères, France
+33 676411296 

 






Le 31 juil. 2015 à 21:09, Niall Ross <[hidden email]> a écrit :

Dear Maarten,
  you can also use the Base64FastCoder class if you wish (in Protocols-Common), via class-side methods #encodeAsBase64String:, #encodeAsBase64ByteArray: and #decodeBase64Encoded:.

This is no different from what Ralf mentioned except that it is faster, but it does not expect or provide any email-usage-style linebreaks.

           Yours faithfully
                 Niall Ross

Excellent  Thanks,
Maarten,


"Ralf Propach" <[hidden email]> |
  




Hi Maarten,

both times you use methods to encode. Try this instead:
ByteArray fromBase64String: 'MO4IEQ==' (gives #[48 238 8 17])


'MO4IEQ==' asByteArrayEncoding: 'Base64'.
is the same as
'MO4IEQ==' asByteArray asBase64String asByteArray.
using the same asBase64String method in both your examples.

Ralf


Am 29.07.2015 09:52, schrieb [hidden email]:
  
Hi,

I have the impression to miss something simple.

I want to encode and decode a ByteArray into and from a Base64 encoded
string.

However I don't manage to do the reverse operation.

#[48 238 8 17] asBase64String *gives: * 'MO4IEQ=='

However

'MO4IEQ==' asByteArrayEncoding: 'Base64'. *gives:*** #[84 85 56 48 83
85 86 82 80 84 48 61]

What do I do wrong ?

Regards,

Maarten MOSTERT

28 Av Alphonse Denis

83400 Hyères, France

+33 676411296

http://stakepoint.com/

    
<https://urldefense.proofpoint.com/v2/url?u=http-3A__stakepoint.com_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=oQmY7z9BeClneFUFwUmfhw&m=oJSTvMWq1l_9N1ek_TCJCbifQ-7tnf0plehdyc3Y50g&s=SCPNz_ERGSRVx3S06At5K9x9ZSd3rBVgKJrjXpYSopo&e=>
  

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

    
  
------------------------------------------------------------------------

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
  




_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc