TheBlueMatt/textsecure-chrome — pull request #9 by Ventero (2014-04-17 14:04:32+00:00)
Title: Password is always "[object ArrayBuffer"

In [`options.js:27`](https://github.com/TheBlueMatt/textsecure-chrome/blob/000a5e1440590381441390ba2b9eee71fa73907e/js/options.js#L27), the password is generated as `btoa(getRandomBytes(16))`.

As documented [on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window.btoa), `btoa` accepts a string argument. However, since [`getRandomBytes`](https://github.com/TheBlueMatt/textsecure-chrome/blob/master/js/helpers.js#L392) returns an `ArrayBuffer`, it is implicitly converted to a string by calling `.toString()` on it - which for an `ArrayBuffer` returns `"[object ArrayBuffer]"`.

In the next line, the last 2 characters of the Base64 encoded password are then removed, effectively setting `password` to `W29iamVjdCBBcnJheUJ1ZmZlcl` (or `[object ArrayBuffer` when decoded).

A possible fix for this would be something like:

```javascript
var password = btoa(getString(getRandomBytes(16)));
```