How to compress email addresses using PoliDataCompressor

PoliDataCompressor.com
Jan 10 · 3 min read

You may have already seen that you can compress numbers using the PoliDataCompressor.js library, and you may already know that compressing data to store them in Blockchain can help you save a lot of money depending on the amount of records entered by your DAPP or SMART CONTRACT.
In today’s topic, we will apply compression to fields with email addresses.


HANDS-ON

Well, to facilitate our learning, open polidatacompressor.com in Google Chrome and right-click choose the last menu option that should be “Inspect” or if you prefer use the shortcut CTRL + SHIFT + I.
A window like the image below will appear.

If you are not in the “Console” option, navigate through the options until you find it.


Compressing email address

To compress fields that have alphanumeric, we must use the command Tcomp (P_1, P_2). This command has two parameters, the first one has the content that we will compress and the second has the list of allowed characters, see:
Tcomp (“polidatacompressor@gmail.com” .toLowerCase (), “abcdefghijklmnopqrstuvwxyz012345679@.-_”)

Note that we have changed the characters of the email to lowercase, since we do not have uppercase characters in the list that we defined in the second parameter.
The twenty-eight character compression representing the email got twenty-one characters to be stored in Blockchain, that is, the reduction of this email was 25%, see:


Uncompressing email address

To decompress we use the command Tdecomp (P_1, P_2). This command has two parameters where the first is the compressed content and the second the same list that we use to compress.

Tdecomp([208,195,36,68,64,5,195,211,64,82,49,77,143,68,30,77,144,48,229,240,52],”abcdefghijklmnopqrstuvwxyz012345679@.-_”)

Caution: The list identified in the second parameter can not be changed after the data has been compressed or reorganized, keep it complete and static.


How to deploy the library in your web application

To deploy just download the .ZIP file on the site itself, unzip and reference the files in the <HEAD> of your HTML page.

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src=”PoliDataCompressor.js”></script>
<script src=”PoliDataCompressor-util.js”></script>
</head>

You must to reference the JQuery library too.


About the license

Don’t worry about the license if your application stay in testing; but if this give to you opportunity to save money, you should contact us and negotiate a license for use.

Thanks for reading

Poli, Marcus

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade