20 lines
429 B
TypeScript
20 lines
429 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) {
|
|
throw new Error("Could not encode base64 string. This should not happen, so why don't you just try again?");
|
|
}
|
|
}
|
|
}
|