check-ethereum-scanner
Version:
Safety checks for new Ethereum tokens
24 lines (18 loc) • 541 B
text/typescript
;
import { arrayify, BytesLike } from "@ethersproject/bytes";
export function decode(textData: string): Uint8Array {
textData = atob(textData);
const data = [];
for (let i = 0; i < textData.length; i++) {
data.push(textData.charCodeAt(i));
}
return arrayify(data);
}
export function encode(data: BytesLike): string {
data = arrayify(data);
let textData = "";
for (let i = 0; i < data.length; i++) {
textData += String.fromCharCode(data[i]);
}
return btoa(textData);
}