Skip to main content
replaced http://tools.ietf.org/html/rfc with https://www.rfc-editor.org/rfc/rfc
Source Link

Javascript, 18 characters

alert(btoa('ÛMx'))

Update: in ES6, using a template literal can save two characters:

alert(btoa`ÛMx`)

The code above is fairly easy to understand by keeping in mind that btoa converts a string into another string according to a set of well-defined rules (RFC 4648RFC 4648). To see how the conversion works, we're going to write the input string "ÛMx" as a sequence of binary digits, where each character is rendered as its 8-bit character code.

Input character          |        Û |        M |        x
Character code (decimal) |      219 |       77 |      120
Character code (binary)  | 11011011 | 01001101 | 01111000

After reorganizing the binary digits in the last row in groups of 6, we get the binary representation of 4 new numbers, corresponding to the Base64 indices of the 4 characters in the string "2014".

Base64 index (binary)  | 110110 | 110100 | 110101 | 111000
Base64 index (decimal) |     54 |     52 |     53 |     56
Output character       |      2 |      0 |      1 |      4

As per HTML specification, the output characters can be retrieved from their Base64 indices according to this table: http://dev.w3.org/html5/spec-LC/webappapis.html#base64-table.

If you don't care about the details, you could let the browser do the calculations for you and find out that "ÛMx" is the result of evaluating atob('2014') in Javascript.

Javascript, 18 characters

alert(btoa('ÛMx'))

Update: in ES6, using a template literal can save two characters:

alert(btoa`ÛMx`)

The code above is fairly easy to understand by keeping in mind that btoa converts a string into another string according to a set of well-defined rules (RFC 4648). To see how the conversion works, we're going to write the input string "ÛMx" as a sequence of binary digits, where each character is rendered as its 8-bit character code.

Input character          |        Û |        M |        x
Character code (decimal) |      219 |       77 |      120
Character code (binary)  | 11011011 | 01001101 | 01111000

After reorganizing the binary digits in the last row in groups of 6, we get the binary representation of 4 new numbers, corresponding to the Base64 indices of the 4 characters in the string "2014".

Base64 index (binary)  | 110110 | 110100 | 110101 | 111000
Base64 index (decimal) |     54 |     52 |     53 |     56
Output character       |      2 |      0 |      1 |      4

As per HTML specification, the output characters can be retrieved from their Base64 indices according to this table: http://dev.w3.org/html5/spec-LC/webappapis.html#base64-table.

If you don't care about the details, you could let the browser do the calculations for you and find out that "ÛMx" is the result of evaluating atob('2014') in Javascript.

Javascript, 18 characters

alert(btoa('ÛMx'))

Update: in ES6, using a template literal can save two characters:

alert(btoa`ÛMx`)

The code above is fairly easy to understand by keeping in mind that btoa converts a string into another string according to a set of well-defined rules (RFC 4648). To see how the conversion works, we're going to write the input string "ÛMx" as a sequence of binary digits, where each character is rendered as its 8-bit character code.

Input character          |        Û |        M |        x
Character code (decimal) |      219 |       77 |      120
Character code (binary)  | 11011011 | 01001101 | 01111000

After reorganizing the binary digits in the last row in groups of 6, we get the binary representation of 4 new numbers, corresponding to the Base64 indices of the 4 characters in the string "2014".

Base64 index (binary)  | 110110 | 110100 | 110101 | 111000
Base64 index (decimal) |     54 |     52 |     53 |     56
Output character       |      2 |      0 |      1 |      4

As per HTML specification, the output characters can be retrieved from their Base64 indices according to this table: http://dev.w3.org/html5/spec-LC/webappapis.html#base64-table.

If you don't care about the details, you could let the browser do the calculations for you and find out that "ÛMx" is the result of evaluating atob('2014') in Javascript.

Update
Source Link
GOTO 0
  • 822
  • 5
  • 14

Javascript, 18 characters

alert(btoa('ÛMx'))

alert(btoa('ÛMx'))
 

JSFiddleUpdate: in ES6, using a template literal can save two characters: http://jsfiddle.net/pBjL2/

alert(btoa`ÛMx`)

Update: the The code above is fairly easy to understand by keeping in mind that btoa converts a string into another string according to a set of well-defined rules (RFC 4648). To see how the conversion works, we're going to write the input string "ÛMx" as a sequence of binary digits, where each character is rendered as its 8-bit character code.

Input character          |        Û |        M |        x
Character code (decimal) |      219 |       77 |      120
Character code (binary)  | 11011011 | 01001101 | 01111000

After reorganizing the binary digits in the last row in groups of 6, we get the binary representation of 4 new numbers, corresponding to the Base64 indices of the 4 characters in the string "2014".

Base64 index (binary)  | 110110 | 110100 | 110101 | 111000
Base64 index (decimal) |     54 |     52 |     53 |     56
Output character       |      2 |      0 |      1 |      4

As per HTML specification, the output characters can be retrieved from their Base64 indices according to this table: http://dev.w3.org/html5/spec-LC/webappapis.html#base64-table.

If you don't care about the details, you could let the browser do the calculations for you and find out that "ÛMx" is the result of evaluating atob('2014') in Javascript.

Javascript, 18 characters

alert(btoa('ÛMx'))

JSFiddle: http://jsfiddle.net/pBjL2/

Update: the code above is fairly easy to understand by keeping in mind that btoa converts a string into another string according to a set of well-defined rules (RFC 4648). To see how the conversion works, we're going to write the input string "ÛMx" as a sequence of binary digits, where each character is rendered as its 8-bit character code.

Input character          |        Û |        M |        x
Character code (decimal) |      219 |       77 |      120
Character code (binary)  | 11011011 | 01001101 | 01111000

After reorganizing the binary digits in the last row in groups of 6, we get the binary representation of 4 new numbers, corresponding to the Base64 indices of the 4 characters in the string "2014".

Base64 index (binary)  | 110110 | 110100 | 110101 | 111000
Base64 index (decimal) |     54 |     52 |     53 |     56
Output character       |      2 |      0 |      1 |      4

As per HTML specification, the output characters can be retrieved from their Base64 indices according to this table: http://dev.w3.org/html5/spec-LC/webappapis.html#base64-table.

If you don't care about the details, you could let the browser do the calculations for you and find out that "ÛMx" is the result of evaluating atob('2014') in Javascript.

Javascript, 18 characters

alert(btoa('ÛMx'))
 

Update: in ES6, using a template literal can save two characters:

alert(btoa`ÛMx`)

The code above is fairly easy to understand by keeping in mind that btoa converts a string into another string according to a set of well-defined rules (RFC 4648). To see how the conversion works, we're going to write the input string "ÛMx" as a sequence of binary digits, where each character is rendered as its 8-bit character code.

Input character          |        Û |        M |        x
Character code (decimal) |      219 |       77 |      120
Character code (binary)  | 11011011 | 01001101 | 01111000

After reorganizing the binary digits in the last row in groups of 6, we get the binary representation of 4 new numbers, corresponding to the Base64 indices of the 4 characters in the string "2014".

Base64 index (binary)  | 110110 | 110100 | 110101 | 111000
Base64 index (decimal) |     54 |     52 |     53 |     56
Output character       |      2 |      0 |      1 |      4

As per HTML specification, the output characters can be retrieved from their Base64 indices according to this table: http://dev.w3.org/html5/spec-LC/webappapis.html#base64-table.

If you don't care about the details, you could let the browser do the calculations for you and find out that "ÛMx" is the result of evaluating atob('2014') in Javascript.

Explanation
Source Link
GOTO 0
  • 822
  • 5
  • 14

Javascript, 18 characters

alert(btoa('ÛMx'))

JSFiddle: http://jsfiddle.net/pBjL2/

Update: the code above is fairly easy to understand by keeping in mind that btoa converts a string into another string according to a set of well-defined rules (RFC 4648). To see how the conversion works, we're going to write the input string "ÛMx" as a sequence of binary digits, where each character is rendered as its 8-bit character code.


Input character          |        Û |        M |        x
Character code (decimal) |      219 |       77 |      120
Character code (binary)  | 11011011 | 01001101 | 01111000

After reorganizing the binary digits in the last row in groups of 6, we get the binary representation of 4 new numbers, corresponding to the Base64 indices of the 4 characters in the string "2014".


Base64 index (binary)  | 110110 | 110100 | 110101 | 111000
Base64 index (decimal) |     54 |     52 |     53 |     56
Output character       |      2 |      0 |      1 |      4

As per HTML specification, the output characters can be retrieved from their Base64 indices according to this table: http://dev.w3.org/html5/spec-LC/webappapis.html#base64-table.

If you don't care about the details, you could let the browser do the calculations for you and find out that "ÛMx" is the result of evaluating atob('2014') in Javascript.

Javascript, 18 characters

alert(btoa('ÛMx'))

JSFiddle: http://jsfiddle.net/pBjL2/

Javascript, 18 characters

alert(btoa('ÛMx'))

JSFiddle: http://jsfiddle.net/pBjL2/

Update: the code above is fairly easy to understand by keeping in mind that btoa converts a string into another string according to a set of well-defined rules (RFC 4648). To see how the conversion works, we're going to write the input string "ÛMx" as a sequence of binary digits, where each character is rendered as its 8-bit character code.


Input character          |        Û |        M |        x
Character code (decimal) |      219 |       77 |      120
Character code (binary)  | 11011011 | 01001101 | 01111000

After reorganizing the binary digits in the last row in groups of 6, we get the binary representation of 4 new numbers, corresponding to the Base64 indices of the 4 characters in the string "2014".


Base64 index (binary)  | 110110 | 110100 | 110101 | 111000
Base64 index (decimal) |     54 |     52 |     53 |     56
Output character       |      2 |      0 |      1 |      4

As per HTML specification, the output characters can be retrieved from their Base64 indices according to this table: http://dev.w3.org/html5/spec-LC/webappapis.html#base64-table.

If you don't care about the details, you could let the browser do the calculations for you and find out that "ÛMx" is the result of evaluating atob('2014') in Javascript.

Rollback to Revision 2
Source Link
null
  • 12.2k
  • 3
  • 58
  • 93
Loading
Alert is not necessary because is already returned to current env
Source Link
Loading
Added character count
Source Link
ProgramFOX
  • 8.3k
  • 7
  • 45
  • 70
Loading
Source Link
GOTO 0
  • 822
  • 5
  • 14
Loading