This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

base64 encoding
#1
Hi,

I am trying to encode the following string with mime.b64 and when I decode it adds this string with a half of the encoded string.  I found the following post regarding this matter in a lua forum,  http://lua-users.org/lists/lua-l/2010-03/msg00832.html.  This looks like exactly what I'm getting.  Any help would be gratefully appreciated.

Thanks,

Roger



{"buttons":[{"name":"Bas \/ Office @ Door \/ Sc1","tags":"bas,btn,office @ door,sc1"},{"name":"Bas \/ Office @ Door \/ Sc2","tags":"bas,btn,office @ door,sc2"},{"name":"Bas \/ Office @ Door \/ Sc3","tags":"bas,btn,office @ door,sc3"},{"name":"Bas \/ Office @ Stairs \/ Sc1","tags":"bas,btn,office @ stairs,sc1"},{"name":"Bas \/ Office @ Stairs \/ Sc2","tags":"bas,btn,office @ stairs,sc2"},{"name":"Bas \/ Office @ Stairs \/ Sc3","tags":"bas,btn,office @ stairs,sc3"},{"name":"Grnd \/ Dining Room @ Stairs \/ Sc1","tags":"btn,dining room @ stairs,grnd,sc1"},{"name":"Grnd \/ Dining Room @ Patio \/ Sc1","tags":"btn,dining room @ patio,grnd,sc1"},{"name":"Grnd \/ Dining Room @ Patio \/ Sc2","tags":"btn,dining room @ patio,grnd,sc2"},{"name":"Grnd \/ Dining Room @ Patio \/ Sc3","tags":"btn,dining room @ patio,grnd,sc3"},{"name":"Grnd \/ Guest WC \/ Sc1","tags":"btn,grnd,guest wc,sc1"},{"name":"Grnd \/ Entrance \/ Sc1","tags":"btn,entrance,grnd,sc1"},{"name":"Grnd \/ Kitchen @ Stairs \/ Sc1","tags":"btn,grnd,kitchen @ stairs,sc1"},{"name":"Grnd \/ Kitchen @ Stairs \/ Sc2","tags":"btn,grnd,kitchen @ stairs,sc2"},{"name":"Grnd \/ Kitchen @ Stairs \/ Sc3","tags":"btn,grnd,kitchen @ stairs,sc3"},{"name":"Grnd \/ Kitchen @ KNX Closet \/ Sc1","tags":"btn,grnd,kitchen @ knx closet,sc1"},{"name":"Grnd \/ Kitchen @ KNX Closet \/ Sc2","tags":"btn,grnd,kitchen @ knx closet,sc2"},{"name":"Grnd \/ Kitchen @ KNX Closet \/ Sc3","tags":"btn,grnd,kitchen @ knx closet,sc3"},{"name":"Grnd \/ living Room @ Sink \/ Sc1","tags":"btn,grnd,living room @ sink,sc1"},{"name":"Grnd \/ living Room @ Sink \/ Sc2","tags":"btn,grnd,living room @ sink,sc2"},{"name":"Grnd \/ living Room @ Sink \/ Sc3","tags":"btn,grnd,living room @ sink,sc3"},{"name":"Grnd \/ living Room @ Stairs \/ Sc1","tags":"btn,grnd,living room @ stairs,sc1"},{"name":"Grnd \/ living Room @ Stairs \/ Sc2","tags":"btn,grnd,living room @ stairs,sc2"},{"name":"Grnd \/ living Room @ Stairs \/ Sc3","tags":"btn,grnd,living room @ stairs,sc3"},{"name":"Grnd \/ Staircase Basement \/ Sc1","tags":"btn,grnd,sc1,staircase basement"},{"name":"Grnd \/ Staircase Basement \/ Sc2","tags":"btn,grnd,sc2,staircase basement"},{"name":"Grnd \/ Staircase Basement \/ Sc3","tags":"btn,grnd,sc3,staircase basement"},{"name":"2nd \/ Bathroom 1 \/ Sc1","tags":"2nd,bathroom 1,btn,sc1"},{"name":"2nd \/ Bathroom 2 \/ Sc1","tags":"2nd,bathroom 2,btn,sc1"},{"name":"2nd \/ Bathroom 2 \/ Sc2","tags":"2nd,bathroom 2,btn,sc2"},{"name":"2nd \/ Bathroom 2 \/ Sc3","tags":"2nd,bathroom 2,btn,sc3"},{"name":"2nd \/ Bedroom 1 @ Door \/ Sc1","tags":"2nd,bedroom 1 @ door,btn,sc1"},{"name":"2nd \/ Bedroom 1 @ Door \/ Sc2","tags":"2nd,bedroom 1 @ door,btn,sc2"},{"name":"2nd \/ Bedroom 1 @ Door \/ Sc3","tags":"2nd,bedroom 1 @ door,btn,sc3"},{"name":"2nd \/ Bedroom 1 @ Bed \/ Sc1","tags":"2nd,bedroom 1 @ bed,btn,sc1"},{"name":"2nd \/ Bedroom 1 @ Bed \/ Sc2","tags":"2nd,bedroom 1 @ bed,btn,sc2"},{"name":"2nd \/ Bedroom 1 @ Bed \/ Sc3","tags":"2nd,bedroom 1 @ bed,btn,sc3"},{"name":"2nd \/ Bedroom 2 @ Door \/ Sc1","tags":"2nd,bedroom 2 @ door,btn,sc1"},{"name":"2nd \/ Bedroom 2 @ Door \/ Sc2","tags":"2nd,bedroom 2 @ door,btn,sc2"},{"name":"2nd \/ Bedroom 2 @ Door \/ Sc3","tags":"2nd,bedroom 2 @ door,btn,sc3"},{"name":"2nd \/ Bedroom 2 @ Bathroom \/ Sc1","tags":"2nd,bedroom 2 @ bathroom,btn,sc1"},{"name":"2nd \/ Bedroom 2 @ Bathroom \/ Sc2","tags":"2nd,bedroom 2 @ bathroom,btn,sc2"},{"name":"2nd \/ Bedroom 2 @ Bathroom \/ Sc3","tags":"2nd,bedroom 2 @ bathroom,btn,sc3"},{"name":"2nd \/ Bedroom 2 @ Bed \/ Sc1","tags":"2nd,bedroom 2 @ bed,btn,sc1"},{"name":"2nd \/ Bedroom 2 @ Bed \/ Sc2","tags":"2nd,bedroom 2 @ bed,btn,sc2"},{"name":"2nd \/ Bedroom 2 @ Bed \/ Sc3","tags":"2nd,bedroom 2 @ bed,btn,sc3"},{"name":"2nd \/ Hallway @ Bedroom 1 \/ Sc1","tags":"2nd,btn,hallway @ bedroom 1,sc1"},{"name":"2nd \/ Hallway @ Master Bedroom \/ Sc1","tags":"2nd,btn,hallway @ master bedroom,sc1"},{"name":"2nd \/ Hallway @ Master Bedroom \/ Sc2","tags":"2nd,btn,hallway @ master bedroom,sc2"},{"name":"2nd \/ Hallway @ Master Bedroom \/ Sc3","tags":"2nd,btn,hallway @ master bedroom,sc3"},{"name":"2nd \/ Hallway @ Her Office \/ Sc1","tags":"2nd,btn,hallway @ her office,sc1"},{"name":"2nd \/ Hallway @ Her Office \/ Sc2","tags":"2nd,btn,hallway @ her office,sc2"},{"name":"2nd \/ Hallway @ Her Office \/ Sc3","tags":"2nd,btn,hallway @ her office,sc3"},{"name":"2nd \/ Hallway @ Staircase \/ Sc1","tags":"2nd,btn,hallway @ staircase,sc1"},{"name":"2nd \/ Hallway @ Staircase \/ Sc2","tags":"2nd,btn,hallway @ staircase,sc2"},{"name":"2nd \/ Hallway @ Staircase \/ Sc3","tags":"2nd,btn,hallway @ staircase,sc3"},{"name":"2nd \/ Her Bathroom @ Sink \/ Sc1","tags":"2nd,btn,her bathroom @ sink,sc1"},{"name":"2nd \/ Her Bathroom @ Sink \/ Sc2","tags":"2nd,btn,her bathroom @ sink,sc2"},{"name":"2nd \/ Her Bathroom @ Sink \/ Sc3","tags":"2nd,btn,her bathroom @ sink,sc3"},{"name":"2nd \/ Her Dressing @ Bedroom \/ Sc1","tags":"2nd,btn,her dressing @ bedroom,sc1"},{"name":"2nd \/ Her Office \/ Sc1","tags":"2nd,btn,her office,sc1"},{"name":"2nd \/ His Bathroom @ Sink \/ Sc1","tags":"2nd,btn,his bathroom @ sink,sc1"},{"name":"2nd \/ Her Dressing @ Bathroom \/ Sc1","tags":"2nd,btn,her dressing @ bathroom,sc1"},{"name":"2nd \/ His Bathroom @ Sink \/ Sc2","tags":"2nd,btn,his bathroom @ sink,sc2"},{"name":"2nd \/ His Bathroom @ Sink \/ Sc3","tags":"2nd,btn,his bathroom @ sink,sc3"},{"name":"2nd \/ His Bathroom @ Door \/ Sc1","tags":"2nd,btn,his bathroom @ door,sc1"},{"name":"2nd \/ His Bathroom @ Door \/ Sc2","tags":"2nd,btn,his bathroom @ door,sc2"},{"name":"2nd \/ His Bathroom @ Door \/ Sc3","tags":"2nd,btn,his bathroom @ door,sc3"},{"name":"2nd \/ Laundry @ Hallway \/ Sc1","tags":"2nd,btn,laundry @ hallway,sc1"},{"name":"2nd \/ Laundry @ Hallway \/ Sc2","tags":"2nd,btn,laundry @ hallway,sc2"},{"name":"2nd \/ Laundry @ Hallway \/ Sc3","tags":"2nd,btn,laundry @ hallway,sc3"},{"name":"2nd \/ Laundry @ Door \/ Sc1","tags":"2nd,btn,laundry @ door,sc1"},{"name":"2nd \/ Master Bedroom @ Bed Left \/ Sc1","tags":"2nd,btn,master bedroom @ bed left,sc1"},{"name":"2nd \/ Master Bedroom @ Bed Left \/ Sc2","tags":"2nd,btn,master bedroom @ bed left,sc2"},{"name":"2nd \/ Master Bedroom @ Bed Left \/ Sc3","tags":"2nd,btn,master bedroom @ bed left,sc3"},{"name":"2nd \/ Master Bedroom @ Bed Right \/ Sc1","tags":"2nd,btn,master bedroom @ bed right,sc1"},{"name":"2nd \/ Master Bedroom @ Bed Right \/ Sc2","tags":"2nd,btn,master bedroom @ bed right,sc2"},{"name":"2nd \/ Master Bedroom @ Bed Right \/ Sc3","tags":"2nd,btn,master bedroom @ bed right,sc3"},{"name":"2nd \/ Master Bedroom @ Hallway \/ Sc1","tags":"2nd,btn,master bedroom @ hallway,sc1"},{"name":"2nd \/ Master Bedroom @ Hallway \/ Sc2","tags":"2nd,btn,master bedroom @ hallway,sc2"},{"name":"2nd \/ Master Bedroom @ Hallway \/ Sc3","tags":"2nd,btn,master bedroom @ hallway,sc3"}],"method":"buttonlist","where":[1,0]}
Reply
#2
You can use built-in encdec library for base64:
http://openrb.com/docs/lua.htm#13
Reply
#3
That works, thank you
Reply
#4
Using the base64 encdec library we encounter a strange behavior in the conversion of the string "rbms".
The result of the reconversion is "rbmss". This does not happen in the case of different strings (see attached image).
We're probably missing something, but we are concerned because we use the conversion base64 to transfer entire libraries in the LM.

Attached Files Thumbnail(s)
   
Reply
#5
This is a bug in encdec. This will be fixed in the next build. In the meantime you can use mime.unb64 from LuaSocket (http://w3.impa.br/~diego/software/luasoc...html#unb64)
Reply
#6
Ok thanks!
Reply


Forum Jump: