PageSourceSearch

https://conversiontab.com/build/assets/base64-tool-page-cdlDvuy6.js

js conversiontab.com collected 2026-09-24 10:07:14 UTC 6,697 bytes, 3 lines download raw bytes

1import{r as M}from"./ctBlobExportFinish-D9AIdnhb.js";import{saveResultFile as k}from"./ctResultAccessAd-Dk9whJZs.js";import{s as $}from"./ctToast-C2BAo121.js";import{bindHashStyleCopy as F}from"./hashStyleCopy-B7l2OPhl.js";import{r as A}from"./runWithButtonBusy-CmZJQ5-c.js";import"./FileSaver.min-BR20wtAe.js";import"./_commonjsHelpers-BosuxZz1.js";import"./ctFullscreenAd-CL-AA_Ul.js";import"./app-gOHIPY12.js";import"./buttonBusy-DoyqFlQ8.js";function E(t){const n=document.getElementById("ctB64ToastBody"),c=document.getElementById("ctB64Toast");if(!n||!c){window.alert(t);return}$(c,{bodyEl:n,message:t,delay:9e3})}function U(t){let n=String(t||"").trim();const c=n.match(/^data:[^;]+;base64,(.+)$/is);return c&&(n=c[1]),n.replace(/\s/g,"")}function W(t){const n=t.length%4;return n===0?t:t+"=".repeat(4-n)}function N(t){const n=W(U(t));if(!n||!/^[A-Za-z0-9+/]+=*$/.test(n))return null;try{const c=new TextDecoder("utf-8",{fatal:!1}),i=atob(n),r=new Uint8Array(i.length);for(let l=0;l<i.length;l++)r[l]=i.charCodeAt(l);return c.decode(r)}catch{return null}}function P(t){const n=new TextEncoder().encode(String(t??""));let c="";for(let i=0;i<n.length;i++)c+=String.fromCharCode(n[i]);return btoa(c)}function z(t){return t.startsWith(`‰PNG\r
2�
3`)?"image/png":t.startsWith("ÿØÿ")?"image/jpeg":t.startsWith("GIF87a")||t.startsWith("GIF89a")?"image/gif":t.startsWith("BM")?"image/bmp":t.startsWith("RIFF")&&t.slice(8,12)==="WEBP"?"image/webp":t.trimStart().startsWith("<svg")?"image/svg+xml":"image/png"}function R(t){const n=String(t||"").trim(),c=n.match(/^data:image\/([a-zA-Z0-9.+-]+);base64,/i),i=W(U(n));if(!i||!/^[A-Za-z0-9+/]+=*$/.test(i))return null;try{const r=atob(i);return`data:${c?`image/${c[1].toLowerCase()}`:z(r)};base64,${i}`}catch{return null}}function Z(t){const n=t.match(/^data:image\/(svg\+xml|vnd\.adobe\.photoshop|x-icon|ico|([a-zA-Z0-9.+-]+));base64,/);return n&&n[1]?n[1]==="vnd.microsoft.icon"||n[1]==="x-icon"?"ico":n[1]==="svg+xml"?"svg":n[1]==="vnd.adobe.photoshop"?"psd":n[1]:null}function ee(){const t=document.getElementById("ct-base64-tool-root");if(!t)return;const n=t.dataset.ctMode||"decoder";if(n==="encoder"){const o=document.getElementById("ctB64EncIn"),e=document.getElementById("ctB64EncOut"),d=document.getElementById("ctB64EncodeBtn"),y=document.getElementById("ctB64ExEncoder"),v=document.getElementById("ctB64ClearEncoder"),m=document.getElementById("ctB64EncDl"),u=document.getElementById("ctB64CopyEnc"),I=document.getElementById("ctB64FileEnc");let x={};const w=document.getElementById("ct-b64-examples");if(w)try{x=JSON.parse(w.textContent||"{}")}catch{x={}}const S=F(u,()=>(e==null?void 0:e.value)||"",E),f=t.querySelector(".ct-codec-workspace__pane--out .ct-codec-workspace__hint"),B=a=>{m&&(m.disabled=!a),u&&(u.disabled=!a),I&&(I.disabled=!a),f instanceof HTMLElement&&(f.textContent=a?"Ready to copy":"Standard Base64 string"),a||S()},s=()=>{var a;d instanceof HTMLButtonElement&&((a=window.getSelection())==null||a.removeAllRanges(),A(d,"Encoding…",()=>{try{const g=P((o==null?void 0:o.value)||"");e&&e.value!==g&&(e.value=g),B(!!g)}catch{e&&(e.value=""),B(!1),E("Could not encode text.")}},{minMs:260,hintEl:f instanceof HTMLElement?f:null,busyHint:"Encoding…",getDoneHint:()=>e!=null&&e.value?"Ready to copy":"Standard Base64 string"}))};y==null||y.addEventListener("click",()=>{o&&(o.value=x.encoderSample||""),s()}),v==null||v.addEventListener("click",()=>{o&&(o.value=""),e&&(e.value=""),B(!1)}),d==null||d.addEventListener("click",s),m==null||m.addEventListener("click",()=>{const a=(e==null?void 0:e.value)||"";if(!a)return;const g=M(I,"base64-encoded",".txt");k(new Blob([a],{type:"text/plain;charset=utf-8"}),g)});return}if(n==="decoder"){const o=document.getElementById("ctB64In"),e=document.getElementById("ctB64OutDec"),d=document.getElementById("ctB64DecodeBtn"),y=document.getElementById("ctB64ExDecoder"),v=document.getElementById("ctB64ClearDecoder"),m=document.getElementById("ctB64CopyDec"),u=document.getElementById("ctB64DlDec"),I=document.getElementById("ctB64FileDec");let x={};const w=document.getElementById("ct-b64-examples");if(w)try{x=JSON.parse(w.textContent||"{}")}catch{x={}}const S=F(m,()=>(e==null?void 0:e.value)||"",E),f=t.querySelector(".ct-codec-workspace__pane--out .ct-codec-workspace__hint"),B=s=>{m&&(m.disabled=!s),u&&(u.disabled=!s),I&&(I.disabled=!s),f instanceof HTMLElement&&(f.textContent=s?"Ready to copy":"Readable UTF-8 text"),s||S()};y==null||y.addEventListener("click",()=>{o&&(o.value=x.decoderSample||""),e&&(e.value=""),B(!1)}),v==null||v.addEventListener("click",()=>{o&&(o.value=""),e&&(e.value=""),B(!1)}),d==null||d.addEventListener("click",()=>{var a;if(!(d instanceof HTMLButtonElement))return;(a=window.getSelection())==null||a.removeAllRanges();const s=(o==null?void 0:o.value)||"";if(!String(s).trim()){E("Enter some Base64 first.");return}A(d,"Decoding…",()=>{const g=N(s);if(g===null){e&&(e.value=""),B(!1),E("Invalid Base64 input.");return}e&&e.value!==g&&(e.value=g),B(!0)},{minMs:260,hintEl:f instanceof HTMLElement?f:null,busyHint:"Decoding…",getDoneHint:()=>e!=null&&e.value?"Ready to copy":"Readable UTF-8 text"})}),u==null||u.addEventListener("click",()=>{const s=(e==null?void 0:e.value)||"";if(!s)return;const a=M(I,"base64-decoded",".txt");k(new Blob([s],{type:"text/plain;charset=utf-8"}),a)});return}const c=document.getElementById("ctB64ImgIn"),i=document.getElementById("ctB64ImgOut"),r=document.getElementById("ctB64ImgPh"),l=document.getElementById("ctB64ToImgBtn"),p=document.getElementById("ctB64DlImg"),C=document.getElementById("ctB64ClearImg"),T=document.getElementById("ctB64ExImg"),b=document.getElementById("ctB64CopyImgUrl");let D={};const H=document.getElementById("ct-b64-examples");if(H)try{D=JSON.parse(H.textContent||"{}")}catch{D={}}let h="";const _=F(b,()=>h||"",E),L=o=>{h=o,o?(i&&(i.src=o,i.classList.remove("d-none")),r&&r.classList.add("d-none"),p&&(p.disabled=!1),b&&(b.disabled=!1)):(i&&(i.removeAttribute("src"),i.classList.add("d-none")),r&&r.classList.remove("d-none"),p&&(p.disabled=!0),b&&(b.disabled=!0,_(
3)))};T==null||T.addEventListener("click",()=>{const o=D.imageSample||"";c&&(c.value=o),L(R(o)||"")}),C==null||C.addEventListener("click",()=>{c&&(c.value=""),L("")}),l==null||l.addEventListener("click",()=>{const o=String((c==null?void 0:c.value)||"").trim(),e=R(o);if(!e){L(""),E("Invalid base64 string.");return}L(e)}),p==null||p.addEventListener("click",()=>{if(!h)return;const o=Z(h);if(o){const e=document.createElement("a");e.href=h,e.download=`converted.${o}`,e.click()}else fetch(h).then(e=>e.blob()).then(e=>void k(e,"converted.png")).catch(()=>E("Download failed."))})}export{ee as initBase64ToolPage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.