mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 10:19:11 +02:00
decode base64
This commit is contained in:
+4
-2
@@ -54,8 +54,10 @@ class Util {
|
||||
return arr;
|
||||
}
|
||||
|
||||
static base64(text) {
|
||||
return Buffer.from(text).toString('base64');
|
||||
static base64(text, mode = 'encode') {
|
||||
if (mode === 'encode') return Buffer.from(text).toString('base64');
|
||||
if (mode === 'decode') return Buffer.from(text, 'base64').toString('utf8');
|
||||
throw new TypeError(`${mode} is not a supported base64 mode.`);
|
||||
}
|
||||
|
||||
static hash(text, algorithm) {
|
||||
|
||||
Reference in New Issue
Block a user