Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[x-license] Use a simpler checksum for the license key #4892

Open
oliviertassinari opened this issue May 15, 2022 · 0 comments
Open

[x-license] Use a simpler checksum for the license key #4892

oliviertassinari opened this issue May 15, 2022 · 0 comments
Labels
dx Related to developers' experience package: x-license Specific to @mui/x-license. performance

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented May 15, 2022

Summary 💡

Using md5 to perform a checksum on the license key feels overkill.

Examples 🌈

Out of this license key:
61628ce74db2c1b62783a6d438593bc5Tz1NVUktRG9jLEU9MTY4MzQ0NzgyMTI4NCxTPXByZW1pdW0sTE09c3Vic2NyaXB0aW9uLEtWPTI=

we have 61628ce74db2c1b62783a6d438593bc5 that is the md5 checksum.

We could replace this with a simpler version:

function hashCode(string){
  return string.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);              
}

(source) which would turn the license key into:
728701898Tz1NVUktRG9jLEU9MTY4MzQ0NzgyMTI4NCxTPXByZW1pdW0sTE09c3Vic2NyaXB0aW9uLEtWPTI=

saving 0.5 kB gzip (from removing md5.js) and 23 characters in the license key.

Motivation 🔦

DX & UX

Order ID 💳 (optional)

No response

@oliviertassinari oliviertassinari added new feature New feature or request package: x-license Specific to @mui/x-license. labels May 15, 2022
@oliviertassinari oliviertassinari changed the title License key, use simpler checksum Use a simpler checksum for the license key May 15, 2022
@joserodolfofreitas joserodolfofreitas added the dx Related to developers' experience label May 16, 2022
@joserodolfofreitas joserodolfofreitas removed the new feature New feature or request label Jun 24, 2022
@oliviertassinari oliviertassinari changed the title Use a simpler checksum for the license key [license] Use a simpler checksum for the license key Sep 12, 2024
@oliviertassinari oliviertassinari changed the title [license] Use a simpler checksum for the license key [x-license] Use a simpler checksum for the license key Dec 25, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
dx Related to developers' experience package: x-license Specific to @mui/x-license. performance
Projects
None yet
Development

No branches or pull requests

2 participants