mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/17010] Clean up code and move some functions to core js
PHPBB3-17010
This commit is contained in:
@@ -1677,6 +1677,33 @@ phpbb.getFunctionByName = function (functionName) {
|
||||
return context[func];
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert raw key ArrayBuffer to base64 string.
|
||||
*
|
||||
* @param {ArrayBuffer} rawKey Raw key array buffer as exported by SubtleCrypto exportKey()
|
||||
* @returns {string} Base64 encoded raw key string
|
||||
*/
|
||||
phpbb.rawKeyToBase64 = (rawKey) => {
|
||||
const keyBuffer = new Uint8Array(rawKey);
|
||||
let keyText = '';
|
||||
const keyLength = keyBuffer.byteLength;
|
||||
for (let i = 0; i < keyLength; i++) {
|
||||
keyText += String.fromCharCode(keyBuffer[i]);
|
||||
}
|
||||
|
||||
return window.btoa(keyText);
|
||||
};
|
||||
|
||||
/**
|
||||
* Base64URL encode base64 encoded string
|
||||
*
|
||||
* @param {string} base64String Base64 encoded string
|
||||
* @returns {string} Base64URL encoded string
|
||||
*/
|
||||
phpbb.base64UrlEncode = (base64String) => {
|
||||
return base64String.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Register page dropdowns.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user