Usage: atob(data) - Converts data to STRING and decodes it from Base64. In contrast, the atob() function decodes a string that has been encoded using the Base64 format and returns it. In JavaScript Base64 values are obtained using the btoa function. The btoa() function returns a Base64 encoded ASCII string from a string of binary data, where each character represents an 8-bit byte. The btoa () method creates a Base64 -encoded ASCII string from a binary string (i.e. This works on almost all modern browsers such as Chrome, Firefox, Safari, Opera, and IE 10+. You can use btoa() and atob() functions, respectively for encoding and decoding Base64 strings. Base64 is commonly used in a number of applications, including email via MIME and storing complex data in XML. This is to ensure that the data remain intact without modification during transport. Each Base64 digit represents exactly 6-bits of data that means 3 bytes can be represented by 4 6-bit Base64 digits.īase64 encoding schemes are commonly used when there is a need to encode binary data that needs to be stored and transferred over media that are designed to deal with textual data. And this atob () method decodes the above Base64 string and returns. This btoa () method simply encodes or creates the Base64 ASCII string from the given file or object. This post will discuss how to encode and decode strings in JavaScript with Base64 format.īase64 is a group of similar binary-to-text encoding schemes representing binary data in an ASCII string format by translating it into a radix-64 representation. These methods atob () and btoa () are used to convert to string and base64 format respectively.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |