Compute md5 checksum of exported images

#1

Just started writing my first plugin. Great docs and welcoming developer experience!

Is there a way to compute checksums of image files exported by the plugin? This is so that I can avoid sending them over the network if they are already present on the server.

#2

@jasim welcome to the community! While XD does not have any API to help you with computing checksums of image files, you can certainly import other external libraries inside your code.

#3

@stevekwak Thanks! https://www.npmjs.com/package/md5 works.

#4

I’ve been using something like openssl dgst -md5 -binary '" + filepath + "' | openssl enc -base64 to compute md5 in other places, by running it as a shell command from JS. openssl, being a native binary, is faster than reading the file and computing the checksum all in Javascript.

Since plugins rightly don’t have shell privileges I think I’ll have to go the slow route. For large designs with dozens of PNGs, it might be far too slow. Just leaving it here if anyone has any better ideas.