Could you use the cordova base64 encode / decode methods here? (1 less file to add, and I'm sure we have the functionality in the project already)
Also, I can't tell what happens if key is not valid base64 -- is there an exception that we should catch?