News Articles base64

Image gray after encoding Base64 in flask

I am sending an image from javascript to flask via base64 but the problem is that I lost the color dimension my javascript code: this is the code send via xmlhttprequest() let base64Image; let openFile = function(e) { let input =; let reader = new FileReader(); reader.onloadend = function(){ let dataURL = reader.result; base64Image […]

Create a qrcode image then convert to base64

I am using to generate qr-code var qrcode = new QRCode("qrcode", { text: "", width: 128, height: 128, colorDark: "#000000", colorLight: "#ffffff", correctLevel: QRCode.CorrectLevel.H }); console.log(qrcode); console.log(qrcode._el.children[1].currentSrc); I can find the base64 code in "qrcode" But why I get empty when I run: console.log(qrcode._el.children[1].currentSrc); Is there any other method to get the base64 code? […]

Problems with base64-encoding a small font-file in Python

I have a small truetype font (9 Kb) that I have downloaded from Google fonts. It represents the Lobster font, but only the letters "Lobster". If you want to replicate, the @font-face is from and I get the font file via the url in the src. You can get the font file via this […]

How to convert private key to base64 format?

I have a private key with below format. The private key is just for test. xprvA3bdZ5Dz3QFmyC6Y7tKeJahknnUZPgpw2Zhf7LNmZ1uLfJo2b557DpPBeBVW6Etbggpnd6VRUEWvKUj3NnBuU1MeWH8CY7eVTQ2yvZUXYSq that is very likely in a Ethereum format. I need to convert it to a base64 format, in order to use it in signatures. (filecoin transaction need to base64 encoded format of privatekey) For sending Filecoin transaction I need […]

reader.readAsDataURL() always returns blob’s MIME type and "[object FileList]"

I’ve been trying to write a script to Base64 encode a font file, and here’s my code: var fileExtension = fontName(".").pop(); if (fileExtension == "ttf") { var blob = new Blob([fontFile], {type: "font/ttf"}); } else if (fileExtension == "otf") { var blob = new Blob([fontFile], {type: "font/otf"}); }; const binaryData = async (blob) => { […]

How to convert Base64 to Image in Scriptable App

I want to convert the Base64 I get from an API into an image in the iOS scriptable app. Here is my current code: let image = How could I convert the base64 into an image? Source: JavaSript – Stack Overflow

How to convert java crypto to nodejs

byte[] bytesDecryptionKey=base64Decode("secretkey"); secretKeyDesKey = SecretKeyFactory.getInstance("DES").generateSecret(new DESKeySpec(bytesDecryptionKey)); String encodedcipherText="EncodedCipherText"; byte[] bytesDecryptedData = decryptString(encodedcipherText, secretKeyDesKey); String strDecryptedData = new String(bytesDecryptedData); Decode the cipher text to text private byte[] decryptString(String str, SecretKey secretKeyDesKey) { String rawString = ""; String formattedString = ""; rawString = str; formattedString = rawString.replaceAll("s",""); byte[] bytesToBeDecrypted = base64Decode(formattedString); byte[] bytesDecryptedData = null; try { […]

can’t create base64 string in safari

I can’t convert an image to a base 64 string in Safari. In all other browsers (desktop and mobile it works). Here is my function to create the url: function toDataURL (src, callback, outputFormat) { var img = new Image() img.crossOrigin = ‘anonymous’ img.src = src img.onload = function () { var canvas = document.createElement(‘CANVAS’) […]

JavaScript reader.readAsDataURL() returns "undefined"

I’ve been trying to find a way to Base64 encode binary data with JavaScript for the past few hours and it turns out that btoa() only works with strings so I came up with the following code, where blob is the file I need to encode: function base64Encode(blob) { var reader = new FileReader(); reader.readAsDataURL(blob) […]

JavaScript reader.readAsDataURL() always returns "undefined"

I’ve been trying to build a website to let users download iOS and iPadOS configuration profiles that install custom fonts on whoever installs them’s devices. Here’s my code: async function configAndDownloadProfile() { var fontPostScriptName = document.getElementById("font-postscript-name").value; var fontFullName = document.getElementById("font-full-name").value; var fontFile = document.getElementById("font-file").files; var fileExtension = fontPostScriptName.split(".").pop(); if (fileExtension === "ttf") { var blob […]

transform a function into a promise based one

I would like to display base64 images in my project. I am having some problems displaying the images on the mobile browser and would like to try to create an asynchronous function to wait until all base64 images are created. Here is a short version of my code: // template // load the raw images […]

Request-URI Too Long on POST request with image data in base64 format

I am trying to upload an image (base64 format) to the server and getting an error "Request-URI Too Long The requested URL’s length exceeds the capacity limit for this server." I looked into some existing questions, where the suggestion was to use the POST method, which I am already doing. Any suggestions on how do […]

An Introduction to Base64 Encoding

Photo by author via Flickr If you are in web development, data engineering, or cybersecurity, you might have heard of Base64. If you’ve seen examples of Base64 text, it looks like gibberish. You might have asked yourself “What is this?”, and more importantly, “What is this used for?” Googling for an answer gives highly technical explanations […]

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.