forked from phuocng/1loc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert a base64 encoded string to an uint8 array
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
snippets/string/convert-a-base64-encoded-string-to-an-uint8-array.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: Convert a base64 encoded string to an uint8 array | ||
category: String | ||
--- | ||
|
||
**JavaScript version** | ||
|
||
```js | ||
const base64ToUint8 = (str) => Uint8Array.from(atob(str), (c) => c.charCodeAt(0)); | ||
``` | ||
|
||
**TypeScript version** | ||
|
||
```js | ||
const base64ToUint8 = (str: string): Uint8Array => Uint8Array.from(atob(str), (c) => c.charCodeAt(0)); | ||
``` | ||
|
||
**See also** | ||
|
||
- [Convert an uint8 array to a base64 encoded string](/string/convert-an-uint8-array-to-a-base64-encoded-string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters