Questions tagged [base64]

Base64 is a set of encoding schemes that represent binary data in an ASCII string format.

Base64 is a group of similar encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The Base64 term originates from a specific MIME content transfer encoding.

Base64 uses characters 0 to 9, A to Z and a to z to represent digits of 64-decimal numbers. The last two required digits differ between schemas. For instance, MIME (RFC 2045) uses + and / , XML names tokens use - and ., XML identifiers use _ and : and regular expressions use ! and -.

When encoding in Base64 text, 3 bytes are typically encoded into 4 characters. To encode arbitrary lengths, the padding character (=) is used. = at the end of encoded sequence means that only two bytes and == means that only one byte is encoded by the last 4 character group.

Characters outside the discussed alphabet are normally forbidden, except in MIME where they are discarded.

Base64 encoding schemes are commonly used when there is a need to encode binary data that need to be stored and transferred over media that are designed to deal with textual data. This is to ensure that the data remain intact without modification during transport. Base64 is commonly used in a number of applications including email via MIME, or to store binary data in textual formats such as XML or JSON.

Useful online tools

They work without enabled JavaScript too.

11149 questions
4
votes
1 answer

hash_hmac() with RAW Binary OUTPUT in JavaScript

I have the php code to generate hash_hmac key = base64_encode(hash_hmac('sha1',$public_key, $private_key,TRUE)); I've tried the CryptoJS library to solve it. According to the documentation: var public_key = 'msg', private_key = 'key'; var hash…
Phantr4x
  • 41
  • 3
4
votes
0 answers

DataImage with comma/base64 encoded - comma disappears

I've a piece of code that is taking an equation and converting it to a .png image for display. If the equation contains a comma(,) - upon conversion to the .png, the , is lost if the image byte string has been base64 encoded. If not, everything is…
Terry Delahunt
  • 616
  • 4
  • 21
4
votes
0 answers

base64 decode image in gif

Faced with such a problem, I can not convert base64 gif string to gif file and save it to disk, with base64 strings getting get its MIME types - application / octet-stream (video streaming), insert the following code (below) and get this error - "…
user2759544
  • 181
  • 1
  • 10
4
votes
1 answer

How can i decode in java a string generated by javascript using readAsDataURL() and sent by Json?

Im trying to decode a string that was genearated by: Javascript code: fileReader.readAsDataURL(fileToLoad); Ps.: Its a part of encode a file. After get the file is encoded, i put inside of Json and send to a restfull service using POST method. Java…
KpsLok
  • 853
  • 9
  • 23
4
votes
1 answer

How to get extension from base64 using c#

I get base64 string as an input to save it as image. but my problem is i dont know what image format user have uploaded. so please help me if anybody know how to get image format or extension from base64 string.
Anand Gaikwad
  • 151
  • 2
  • 9
4
votes
2 answers

PHP Base64 encoding for JSON slash issue

I am using Elastic-PHP API 2.0 to create an index of Word and PDF documents. This normally requires to send a Base64 encoding of the document as JSON to its Mapper attachment plugin. However, PHP's Base64 generates slashes \ in the encoded string.…
dr_rk
  • 4,395
  • 13
  • 48
  • 74
4
votes
2 answers

Generating Thumbnail C# from base64string

I am trying to generate a thumbnail from the base64string. I am storing the image in a table and am trying to generate a thumbnail from the base64string being stored. I am able to generate the thumbnail if I provide a path to the image, but that…
Code
  • 1,969
  • 3
  • 18
  • 33
4
votes
1 answer

Unexplained code appearing in all php files

I have this code on top of all my php files in the source control somehow Can you someone please shed some light on what this is? EDIT: I know its most likely bad, I know that it is trying to create functions. But what exactly are those functions…
Vish
  • 4,508
  • 10
  • 42
  • 74
4
votes
0 answers

Unable to download base64 encoded image on Chrome

I have an app that, when clicking on a link, opens a new window with the following code: On Chrome, if I right-click and select Save image…
mornaner
  • 2,424
  • 2
  • 27
  • 39
4
votes
1 answer

Lua Base64 Encode

I dont use lua and I tried to search on internet, what this do: assert`(load(Base64Decode(==BASE64 Script but is not Encoded like usualy==), nil, "bt", _ENV))().` Every encoded message starts with G0x........==. I tried mathematical decoding but…
ChrystianSandu
  • 73
  • 1
  • 1
  • 9
4
votes
1 answer

Issue Converting a Base64 string to a Hex string

TLDR: What is the edge case that I'm missing, or is there a mistake in my algorithm for converting a Base64 string to a Hex string? I recently decided to try the Matasano Crypto Challenges, however for whatever reason, I decided to try and write…
Asmodean
  • 339
  • 3
  • 13
4
votes
1 answer

Utilities base64Encode versus base64Decode method

Why the base64Decode can't decode something just encoded by base64Encode? function test_base64encoding_decoding() { var file = DriveApp.getFileById(""); // Encode file bytes as a string var base64EncodedBytes =…
A. Masson
  • 2,287
  • 3
  • 30
  • 36
4
votes
1 answer

Securely decoding a Base64 character array in Java

I need to decode a Base64 char array without converting it to a String. The char array is a password, and for security reasons I am not allowed to convert it to a String (this requirement is non-negotiable). The java.util.Base64.Decoder.decode…
Groppe
  • 3,819
  • 12
  • 44
  • 68
4
votes
4 answers

Most memory-efficient way of holding base64 data in Python?

Suppose you have a MD5 hash encoded in base64. Then each character needs only 6 bits to store each character in the resultant 22-byte string (excluding the ending '=='). Thus, each base64 md5 hash can shrink down to 6*22 = 132 bits, which requires…
OTZ
  • 3,003
  • 4
  • 29
  • 41
4
votes
1 answer

How to add padding before decoding a base64 string?

ColdFusion's binaryDecode(input, 'base64') is picky because padding is mandatory. What is the correct way to add padding with = to a base64 value? 1.) Ben Nadel uses: value &= repeatString( "=", ( 4 - ( len( value ) % 4 ) ) ); 2.) Arlo Carreon…
Henry
  • 32,689
  • 19
  • 120
  • 221