The BlackBerry WebWorks SDK for Tablet OS build tool generates an archive that contains the files and a MANIFEST.MF with entry for each file and a base64 encoded SHA512 digest. However, there is a bug that too many files in the build will cause a build failure. I am trying to figure out how to generate that same information myself.
The example below comes from the MANIFEST.MF
and it contains the filename and digest. However, the base64 variant uses _
instead of /
and -
instead of +
and has no trailing ==
for padding.
Archive-Asset-Name: air/XX/IMG_0999.jpg
Archive-Asset-SHA-512-Digest: YI_KXWjpJwwsi5MDQPeBQc9SVi-bH6zYq5PgBD3jQiqHu-r-5Hv8A0yh_y5j2T9MpYZ5TVMW4JXHSXNYmpV1tA
I running Windows 7, but have GIT installed so I have MINGW32 as a bash shell. I found this piped combination of openssl and tr commands but it seems a bit of a kludge.
openssl dgst -sha512 -binary IMG_0999.gif | openssl enc -base64 | tr '+' '-' | tr '/' '_' | tr -d '=' | tr -d '\n'
Is there a better way to generate this digest?
Eventually, I will have to do for all the images in a directory tree. I was hoping for a script solution instead of having to write a program. A second question is how to generate that manifest syntax for all files in a directory (recursively). Would this be a bash shell script encompassing the above command? Any pointers here are appreciated since I haven't written a shell script before.
Dennis Williamson's solution got me going but the
tr
version (2.0) that is installed did like that multiple character syntax. Also, thexargs
version (4.1) didn't like the-I
option. However, it got me started and that is what matters. Here is what I ended up with:and that generates the following (images names changed to protect the innocent)
I still need to tweak the name to not be prefixed with
./
but that is for another day.