Bookmark this: tool.io/encode/base64/source-code
Encode Base64 Source Code
Browse the implementation files for Encode Base64.tool.ts typescript
import { encodeBase64 as encodePortableBase64 } from '@tool.io/tools/encode/base64';
export const base64Encode = (input: unknown): string => {
if (typeof input !== 'string' || input === '') return '';
try {
return encodePortableBase64(input);
} catch {
return '';
}
};
// The tool definition.
export const Tool: TypeTool = {
name: 'Encode Base64',
slug: 'encode/base64',
intro:
'Base64 Tool enables you to decode base64 and encode text to base64.',
description:
'Base64 converts binary data into text that can be stored or transferred in text-based formats. Use this tool to encode text as Base64 or decode Base64 back into readable text. Base64 is an encoding format, not encryption, and should not be used to protect sensitive information.',
tool: base64Encode,
i: [
{
example: 'Tool.io is awesome!',
help: 'Type some text, e.g.',
label: 'Text',
placeholder: 'Paste text to encode as Base64 here...',
placeholderswap: 'Paste Base64 to decode here...',
type: 'text',
render: 'textarea'
}
],
o: [
{
example: 'VG9vbC5pbyBpcyBhd2Vzb21lIQ==',
help: 'Paste Base64 here, e.g. ',
label: 'Base64',
placeholder: 'Encoded Base64 will appear here...',
placeholderswap: 'Decoded text will appear here...',
type: 'text',
render: 'textarea'
}
],
swap: {
state: false,
name: 'Base64 Decode',
target: 'decode/base64'
},
alternative: [
{ title: 'Base64 Decode', url: '/decode/base64' }
],
equation:
'$$ Base64(\\text{tool.io}) \\rightarrow \\text{dG9vbC5pbw==} $$',
cite: [
{
title: 'Base64 - Mozilla',
url: 'https://developer.mozilla.org/en-US/docs/Glossary/Base64'
}
]
};
export default Tool;
Description
Browse the implementation files for Encode Base64.