The baseto64 library I used was not generating the correct value all the time. Removed it and am going with the native implementation.