base64encode/DB replacing all "+" symbols with "space" ?

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

bogs
Posts: 2287
Joined: Sat Feb 25, 2017 10:45 pm

Re: base64encode/DB replacing all "+" symbols with "space" ?

Post by bogs » Thu Feb 08, 2018 7:06 am

FourthWorld wrote:
Wed Feb 07, 2018 10:20 pm
If we conservatively assume that all of us have collectively spent ~10 hours trying to find workarounds for the formatting issues inherent in using base64 for hashes, the system would need to transmit hashes 3,025,210,084 times before the 40-bytes savings hits break-even.
Although I have not (yet) spent any time on finding a work around for this, pragmatically, I'd say he has a point.
Image

MaxV
Posts: 1540
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: base64encode/DB replacing all "+" symbols with "space" ?

Post by MaxV » Thu Feb 08, 2018 12:27 pm

FourthWorld wrote:
Wed Feb 07, 2018 10:20 pm
MaxV wrote:
Wed Feb 07, 2018 6:09 pm
FourthWorld wrote:
Wed Feb 07, 2018 2:50 pm
Use hex rather than base64 and all this goes away.
However base64encode produce shorter strings, so in case of bigger data, it saves much more space/bandwidth/time.
The difference in length between a hex representation of a SHA3 hash and a base64 representation is ~40 bytes. ....
:lol: exactly, but I wrote in case of bigger data.

Example: Image of 1.2Mb, base64encode is 462'028 chars shorter than hex.
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

sphere
Posts: 702
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth

Re: base64encode/DB replacing all "+" symbols with "space" ?

Post by sphere » Thu Feb 08, 2018 2:47 pm

Richard,
you know that Italians do everything to get every horsepower they can get :)
Speed is everything.
:D :o :) :shock: 8) :lol:

bogs
Posts: 2287
Joined: Sat Feb 25, 2017 10:45 pm

Re: base64encode/DB replacing all "+" symbols with "space" ?

Post by bogs » Thu Feb 08, 2018 2:56 pm

Hey, I partially resemble that remark! :P Must be the other parts of my ancestry just don't care enough heh :twisted:
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6173
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: base64encode/DB replacing all "+" symbols with "space" ?

Post by FourthWorld » Thu Feb 08, 2018 7:30 pm

MaxV wrote:
Thu Feb 08, 2018 12:27 pm
FourthWorld wrote:
Wed Feb 07, 2018 10:20 pm
MaxV wrote:
Wed Feb 07, 2018 6:09 pm


However base64encode produce shorter strings, so in case of bigger data, it saves much more space/bandwidth/time.
The difference in length between a hex representation of a SHA3 hash and a base64 representation is ~40 bytes. ....
:lol: exactly, but I wrote in case of bigger data.

Example: Image of 1.2Mb, base64encode is 462'028 chars shorter than hex.
At the average Internet speed that would save 0.141689 seconds per transfer. Modest, but approaching thresholds one might care about, which is why most people POST binary data to servers as base64 (though even faster to just leave it as binary as a File object).

In a thread about image uploads that would be a good thing to keep in mind. But in this thread about hashes we're dealing with very different requirements.

I don't think there's a one-size-fits-all solution for anything, certainly not for transmission formats. We use what's best for the unique characteristics of the task at hand.

If we look around on the 'net we see that hashes are most commonly transferred (and even stored) as hex. I've seen a few discussions about base64 and other formats for this purpose, but most of those discussions tend to reflect this thread: while it's possible to use base64 for hashes, most people prefer to avoid the challenges involved and just stick with hex instead.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

teriibi
Posts: 254
Joined: Mon Nov 13, 2017 3:49 pm
Location: Bolivia

Re: base64encode/DB replacing all "+" symbols with "space" ?

Post by teriibi » Thu Feb 08, 2018 11:50 pm

I took my time to specialy create another clear stack - I tested it before uplading the Zip - it works perfectly with my server and DBs.
The only remaining problem is that it retreives extra unwanted characters.
so one is not too sure after all the extra work how to understand :
In short, I don't believe this is the actual code you are attempting to use.

:shock: :shock: :shock: where there is not trust...there is not deal
Last edited by teriibi on Fri Feb 09, 2018 1:50 am, edited 1 time in total.

teriibi
Posts: 254
Joined: Mon Nov 13, 2017 3:49 pm
Location: Bolivia

Re: base64encode/DB replacing all "+" symbols with "space" ?

Post by teriibi » Fri Feb 09, 2018 1:49 am

Ok, summing up,

I came to use the HEX function has follow :
it does give me good results for both, sending & retreving strings
(still there is a diference in lenght)

Code: Select all

put messageDigest(tinputA, "SHA3-512") into tAH
   get binarydecode("H*",tAH,tstringA) //Create 1rst String value to compare.
   put tstringA into fld "StringA"
...I added a bynarydecode to display the string in a field, otherwise I cant compare them visualy, right ?

as for the URLencode produced string, I keep loosing the code I had found to build it from the retreived value...so nothing for the moment... :x :x

teriibi
Posts: 254
Joined: Mon Nov 13, 2017 3:49 pm
Location: Bolivia

SOLVED - Re: base64encode/DB replacing all "+" symbols with "space" ?

Post by teriibi » Fri Feb 09, 2018 4:21 am

Wahhh, ITS SOLVED :lol: !!!

As for this case - the BynaryHex function (quoted above) was the only function necessary to avoid "+" symbols to turn into " " (spaces). :evil: 8)

Plus - the extra - unwanted caracters which gave the retreived string a diferent lenght was because of an unapropriate PARSING of the retreived value that ghettocottage helped solving through another topic :wink:
Thanks to all for their time and will to help :mrgreen:

Post Reply

Return to “Internet”