converter/src/app/converter/base64encoder.ts

21 lines
618 B
TypeScript

import {Converter} from "./converter";
export class Base64Encoder implements Converter {
getDisplayname(): string {
return "Encode Base 64";
}
getId(): string {
return "base64encode";
}
convert(input: string): string {
try {
return btoa(input);
} catch (exception) {
console.error(exception);
throw new Error("Ouch! Looks like you've got a UTF-8 character there. Too bad, this is not supported yet. We're working on it and hope to be ready soon! Why don't you <a href=\"https://duckduckgo.com/?q=cute+kitties&iar=images\">enjoy some kittens</a> meanwhile?");
}
}
}