Skip to content

Commit

Permalink
add base64 converter util script
Browse files Browse the repository at this point in the history
  • Loading branch information
Whytecrowe committed Dec 19, 2023
1 parent 1fb6127 commit 0d645ed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"gas-cost": "ts-node src/utils/gas-costs.ts",
"docgen": "hardhat docgen",
"save-tag": "chmod a+x ./src/utils/git-tag/save-tag.sh && bash ./src/utils/git-tag/save-tag.sh",
"base64": "ts-node src/utils/convert-base64.ts",
"mongo:start": "docker-compose up -d",
"mongo:stop": "docker-compose stop",
"mongo:down": "docker-compose down",
Expand Down
19 changes: 19 additions & 0 deletions src/utils/convert-base64.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


const toBase64 = (str : string) => btoa(str);

const fromBase64 = (str : string) => atob(str);

const [
toOrFrom,
str,
] = process.argv.slice(2);


if (toOrFrom === "to") {
console.log(toBase64(str));
} else if (toOrFrom === "from") {
console.log(fromBase64(str));
} else {
console.log("Invalid arguments");
}

0 comments on commit 0d645ed

Please sign in to comment.