1. #1
    Sencha User
    Join Date
    Oct 2007
    Location
    Berlin, Germany
    Posts
    888
    Vote Rating
    9
    wm003 will become famous soon enough

      1  

    Post Ext.util.MD5

    Ext.util.MD5


    i found this code years ago somewhere on the net and "ported" it to Ext...as it wasnt Part of the existing crypto Plugin that only contains SHA-1 (yes, i know SHA-1 is more secure because of 160-Bit instead of 128-Bit with MD5, but as MD5 is furthermore used in many applications and i needed it for my old and current projects, i hope this is useful for someone else also )

    It works exactly like the PHP function md5()

    [UPDATE 2008/03/20]
    - added optional parameters for raw binary output of a 16 letter binary string instead of the 32 Bit hex-string
    - moved the hexcase parameter as optional parameters to the function call (default to false=> lowercase)
    - moved the charset parameter as optional parameters to the function call (default to 8=> ASCII)
    - passes the jslint test now

    Usage:
    string Ext.util.MD5 ( string str [, bool raw_output ][, bool hexcase ][, number charset {8(ASCII):16(UNICODE)} ] )

    [code]
    var MD5Hash = Ext.util.MD5("testtext"); //returns 0ea2d99c9848117666c38abce16bb43e
    var MD5Hash = Ext.util.MD5("testtext",false,true); //returns 0EA2D99C9848117666C38ABCE16BB43E
    var MD5Hash = Ext.util.MD5("testtext",true); //returns binary string
    Attached Files

  2. #2
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,509
    Vote Rating
    374
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Thank you very much for sharing. I already use some md5 function but I like your Ext-ish version more.

    Any license or conditions of use?
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  3. #3
    Sencha User
    Join Date
    Oct 2007
    Location
    Berlin, Germany
    Posts
    888
    Vote Rating
    9
    wm003 will become famous soon enough

      0  

    Default


    Quote Originally Posted by jsakalos View Post
    Thank you very much for sharing. I already use some md5 function but I like your Ext-ish version more.

    Any license or conditions of use?

    As the algoryhtm is freely available here this piece of code can be used freely without any conditions by anyone using Ext

  4. #4
    Sencha User garraS's Avatar
    Join Date
    Oct 2007
    Location
    Argentina
    Posts
    203
    Vote Rating
    0
    garraS is on a distinguished road

      0  

    Default


    Awesome!
    Useful tool.

    Thanks!

  5. #5

  6. #6
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,509
    Vote Rating
    374
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Doing a "Qual Check" on files of my application, the Ext.util.MD5 is the part of, I found that running it through http://jslint.com spits out errors.

    Could you please run it through jslint and fix these errors?
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  7. #7
    Sencha User
    Join Date
    Oct 2007
    Location
    Berlin, Germany
    Posts
    888
    Vote Rating
    9
    wm003 will become famous soon enough

      0  

    Default


    Quote Originally Posted by jsakalos View Post
    Could you please run it through jslint and fix these errors?
    Done so. I updated my original post at the top.
    The only thing jslint moans at least is that "Ext" has not been defined, what is ok here, as the function assumes "Ext.util" is still present.

  8. #8
    Ext User
    Join Date
    Jul 2007
    Location
    Washington, DC
    Posts
    190
    Vote Rating
    0
    esoteric is on a distinguished road

      0  

    Default


    Thanks for the code, you may want to post it under the extension section of the site. But this will be extremely helpful.

  9. #9
    Sencha User
    Join Date
    Mar 2007
    Posts
    580
    Vote Rating
    0
    dolittle is an unknown quantity at this point

      0  

    Default


    I'm using md5 javascript implementation for SASL Difest MD5
    http://pajhome.org.uk/crypt/md5/

    I'm using the functions
    Code:
    function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
    function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
    Is it possible to achieve the same with your extension?

    If it isn't, could you extend it to use these functions?

    Thanks

  10. #10
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,509
    Vote Rating
    374
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Quote Originally Posted by wm003 View Post
    Done so. I updated my original post at the top.
    The only thing jslint moans at least is that "Ext" has not been defined, what is ok here, as the function assumes "Ext.util" is still present.
    Super, thank you. BTW, if you put /*global Ext */ at the beginning of the file jslint is satisfied as he knows that you know about the global Ext.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM