mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-14 15:56:38 +03:00
Use standard base64 encoding in FairPlay license request (#1932)
Closes #1915
This commit is contained in:
@@ -26,6 +26,18 @@ goog.require('shaka.util.StringUtils');
|
||||
* @exportDoc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Convert a Uint8Array to a base64 string. The output will be standard alphabet
|
||||
* as opposed to base64url safe alphabet.
|
||||
* @param {!Uint8Array} u8Arr
|
||||
* @return {string}
|
||||
* @export
|
||||
*/
|
||||
|
||||
shaka.util.Uint8ArrayUtils.toStandardBase64 = function(u8Arr) {
|
||||
const bytes = shaka.util.StringUtils.fromCharCode(u8Arr);
|
||||
return btoa(bytes);
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert a Uint8Array to a base64 string. The output will always use the
|
||||
@@ -37,14 +49,12 @@ goog.require('shaka.util.StringUtils');
|
||||
* @export
|
||||
*/
|
||||
shaka.util.Uint8ArrayUtils.toBase64 = function(arr, padding) {
|
||||
// btoa expects a "raw string" where each character is interpreted as a byte.
|
||||
const bytes = shaka.util.StringUtils.fromCharCode(arr);
|
||||
padding = (padding == undefined) ? true : padding;
|
||||
const base64 = window.btoa(bytes).replace(/\+/g, '-').replace(/\//g, '_');
|
||||
const base64 = shaka.util.Uint8ArrayUtils.toStandardBase64(arr)
|
||||
.replace(/\+/g, '-').replace(/\//g, '_');
|
||||
return padding ? base64 : base64.replace(/=*$/, '');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Convert a base64 string to a Uint8Array. Accepts either the standard
|
||||
* alphabet or the alternate "base64url" alphabet.
|
||||
|
||||
Reference in New Issue
Block a user