Hybrid View

  1. #1
    Sencha User
    Join Date
    Oct 2007
    Location
    Berlin, Germany
    Posts
    891
    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,538
    Vote Rating
    380
    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
    891
    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,538
    Vote Rating
    380
    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
    Ext User
    Join Date
    Oct 2008
    Posts
    23
    Vote Rating
    0
    Nand@ is on a distinguished road

      0  

    Default


    hi, i want to do a "retrieve password" read from database n show it in a form..like you said this plugin "It works exactly like the PHP function md5()" but i canot "retrieve" the md5 encrypted password n show it like php function just encrypted the text and send it to server side not the opossite...any sugesstion? thanks in advance!

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

      0  

    Default


    Quote Originally Posted by Nand@ View Post
    hi, i want to do a "retrieve password" read from database n show it in a form..like you said this plugin "It works exactly like the PHP function md5()" but i canot "retrieve" the md5 encrypted password n show it like php function just encrypted the text and send it to server side not the opossite...any sugesstion? thanks in advance!

    mmh, i don't quite understand:

    like i stated in the first post:

    PHP Code:
    var MD5Hash Ext.util.MD5("testtext"); //returns 0ea2d99c9848117666c38abce16bb43e
    document.write(MD5Hash); 
    This "retrieves" the MD5-Hash of the password "testtext" into the JS-Var MD5Hash and outputs it into the briowser document
    The php-function does the same....

    PHP Code:
    $md5hash md5("testtext");
    echo 
    $md5hash

  9. #9
    Ext User
    Join Date
    Oct 2008
    Posts
    23
    Vote Rating
    0
    Nand@ is on a distinguished road

      0  

    Default


    Quote Originally Posted by wm003 View Post

    mmh, i don't quite understand:

    like i stated in the first post:

    PHP Code:
    var MD5Hash Ext.util.MD5("testtext"); //returns 0ea2d99c9848117666c38abce16bb43e
    document.write(MD5Hash); 
    This "retrieves" the MD5-Hash of the password "testtext" into the JS-Var MD5Hash and outputs it into the briowser document
    The php-function does the same....

    PHP Code:
    $md5hash md5("testtext");
    echo 
    $md5hash
    yep i understend you..but, if you use a
    PHP Code:
    $md5hash md5("testtext");
    echo 
    $md5hash
    show something like 0ea2d99c9848117666c38abce16bb43e AND if you "read" the database AND the password is already encrypted then show you "testtext" ..so i want to know how get the "two" ways: encrypt and decrypt the string...like the md5 php function...
    another comparison: if you wanna know the password from a user well we need to decrypt the encrypted password reading the database n show it "plain text" but if you want to "save" the password from a user well we use a md5(password) to encrypt the plain text...

    i hope you understand..thanks

  10. #10
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    6
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    encryption is one way. You can't decrypt in php either. Do like the norm, reset the password if someone forgets it.