converter/src/app/converter/base64decoder.ts

20 lines
393 B
TypeScript
Raw Normal View History

2017-04-15 19:04:49 +02:00
import {Converter} from './converter';
export class Base64Decoder implements Converter {
getDisplayname(): string {
2017-04-15 19:04:49 +02:00
return 'Decode Base 64';
}
getId(): string {
2017-04-15 19:04:49 +02:00
return 'base64decode';
}
convert(input: string): string {
try {
return atob(input);
} catch (exception) {
2017-04-15 19:04:49 +02:00
throw new Error('Could not decode base64 string. Maybe corrupt input?');
}
}
}