Categories

jQuery.toBASE64()

Categories: Utilities

jQuery.toBASE64( object, [ traditional ] )Returns: String

Plugin: jQuery.base64

Description: Encrypt a text or object as base64 string.

  • jQuery.toBASE64( object, [ traditional ] )

    version added: 1.3

    object   A object to encrypt

    traditional   A boolean indicating whether to use the traditional mode else convert to json before encrypt.

The jQuery.toBASE64() method encrypts objects to base64 string, is support not only strings, because it converts the object to an json string before encrypt base64.

For browsers which don't support a native base64 methods, the jQuery.base64 plugin will load the jQuery.base64.fix plugin automatically.

  • Encrypt objects as base64.

    Code:
    $.toBASE64({
        foo: 'bar'
    });
    
    $.toBASE64(['foo', 'bar']);
    
    $.toBASE64(12345);
    
    $.toBASE64('Lorem ipsum');
  • Encrypt string as base64 with json convert.

    Code:
    $.toBASE64( 'Lorem ipsum' );
    Results:
    IkxvcmVtIGlwc3VtIg==
  • Encrypt string as base64 without json convert.

    Code:
    $.toBASE64 'Lorem ipsum', true );
    Results:
    TG9yZW0gaXBzdW0=

jQuery.toBASE64( object, [ traditional ] )Returns: String

Plugin: jQuery.base64.fix

Description: Encrypt a text or object as base64 string.

  • jQuery.toBASE64( object, [ traditional ] )

    version added: 1.3

    object   A object to encrypt

    traditional   A boolean indicating whether to use the traditional mode else convert to json before encrypt.

The jQuery.toBASE64() method encrypts objects to base64 string, is support not only strings, because it converts the object to an json string before encrypt base64.

The jQuery.base64.fix plugin is specially built, for browsers which don't support native base64 methods.