Page MenuHomePhorge

base64.js
No OneTemporary

Size
913 B
Referenced Files
None
Subscribers
None

base64.js

import { test, summary } from './helpers.js';
console.log('Base64 Tests\n');
test('btoa Hello World', btoa('Hello, World!'), 'SGVsbG8sIFdvcmxkIQ==');
test('atob Hello World', atob('SGVsbG8sIFdvcmxkIQ=='), 'Hello, World!');
const original = 'The quick brown fox jumps over the lazy dog';
test('roundtrip', atob(btoa(original)), original);
test('btoa empty', btoa(''), '');
test('atob empty', atob(''), '');
test('btoa single char', btoa('A'), 'QQ==');
test('btoa two chars', btoa('AB'), 'QUI=');
test('btoa three chars', btoa('ABC'), 'QUJD');
test('roundtrip numbers', atob(btoa('12345')), '12345');
const special = '!@#$%^&*()';
test('roundtrip special', atob(btoa(special)), special);
const jsonData = '{"name":"test","value":123}';
test('roundtrip json', atob(btoa(jsonData)), jsonData);
test('btoa binary', btoa('\x00\x01\x02'), 'AAEC');
test('atob binary', atob('AAEC'), '\x00\x01\x02');
summary();

File Metadata

Mime Type
application/javascript
Expires
Sat, Mar 28, 12:52 AM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
513385
Default Alt Text
base64.js (913 B)

Event Timeline