This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 28551 - TODO: create example utility function that converts text -> ArrayBufferView
Summary: TODO: create example utility function that converts text -> ArrayBufferView
Status: RESOLVED MOVED
Alias: None
Product: Web Cryptography
Classification: Unclassified
Component: Web Cryptography API Document (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Ryan Sleevi
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-23 16:44 UTC by Martin Thomson
Modified: 2016-05-24 00:33 UTC (History)
4 users (show)

See Also:


Attachments
Utility functions for converting text, base64, arrayBuffer (1.05 KB, application/javascript)
2015-04-23 19:30 UTC, Adam Hart
Details

Description Martin Thomson 2015-04-23 16:44:37 UTC
Maybe use TextEncoder: https://encoding.spec.whatwg.org/#interface-textencoder
Comment 1 Adam Hart 2015-04-23 19:30:16 UTC
Created attachment 1598 [details]
Utility functions for converting text, base64, arrayBuffer

These have consistently worked for any UTF-8 I've thrown at them for use with the web crypto API's
Comment 2 Adam Hart 2015-04-23 19:49:49 UTC
Comment on attachment 1598 [details]
Utility functions for converting text, base64, arrayBuffer

There are a few typos in the last two functions. Should be obvious, just remove the underscores. Sorry for that and for possibly not submitting this correctly -- first time on here.
Comment 3 Tim Taubert 2015-04-24 07:16:35 UTC
(In reply to Adam Hart from comment #1)
> Created attachment 1598 [details]
> Utility functions for converting text, base64, arrayBuffer

Converting string->base64 and then base64->abv (or the other way around) is not something we should suggest doing. TextEncoder, as mentioned by Martin above, is an API made for exactly that. I've used it for all my examples so far and I think we should use it here too.
Comment 4 Mark Watson 2016-05-24 00:33:33 UTC
Moved to https://github.com/w3c/webcrypto/issues/81