If you use Github (or bit torrent sites), you'll notice that there is sometimes a code called a sha used to reference files. This is actually a hash of the contents of the file. If you change the contents then the hash changes, so its a good way to know if there's been any updates or indeed if two files are the same as each other. It's also used to enable a concept known as 'content addressable files'. GitHub is based on this, and files can be found by their hash. It is fairly straightforward to create a sha out of any content using apps script. The sha for
is
You'll find these snippets in the cUseful library, or you can see the code below. so to create the sha above, you would use
The code
The cUseful library Many of the snippets in this section of the site are part of the cUseful library. You can find the details below. And that's all there is to it. Happy hashing For more like this, see Google Apps Scripts snippets. Why not join our forum,follow the blog or follow me on twitter to ensure you get updates when they are available. |
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Google Apps Scripts snippets >