Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Use abab instead of atob/btoa
Browse files Browse the repository at this point in the history
  • Loading branch information
cschleiden committed Aug 23, 2021
1 parent 1638a07 commit b17ee4b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/secrets/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import sodium = require("tweetsodium");
import atob = require("atob");
import btoa = require("btoa");
import util = require("util");
import { atob, btoa } from "abab";

function decode(encoded: string): Uint8Array {
const bytes = atob(encoded)
const bytes = atob(encoded)!
.split("")
.map((x: string) => x.charCodeAt(0));
return Uint8Array.from(bytes);
}

function encode(bytes: Uint8Array): string {
return btoa(String.fromCharCode.apply(null, Array.from(bytes)));
return btoa(String.fromCharCode.apply(null, Array.from(bytes)))!;
}

export function encodeSecret(key: string, value: string): string {
Expand Down

0 comments on commit b17ee4b

Please sign in to comment.