Java MD5 for Linux

Hi @all
I'm trying to write a method in Java, that receives a String and should return the MD5 hash of this String.
This hash should be usable to change the password of a user in linux with usermod -p "hash" user.
Here is my method:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<BEGIN>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
public String createMD5HashCode(String text) throws NoSuchAlgorithmException, NoSuchProviderException {
String result = text;
if (text != null) {
StringBuffer code = new StringBuffer(); //the hash code
String plain = text;
byte bytes[] = plain.getBytes();
MessageDigest messageDigest = MessageDigest.getInstance("MD5", "SUN");
messageDigest.update(bytes);
byte digest[] = messageDigest.digest(bytes); //create code
System.out.println(digest.length);
for (int i = 0; i < digest.length; ++i) {
code.append(Integer.toHexString(0x0100 + (digest & 0x00FF)).substring(1));
result = code.toString();
return result;
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<END>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
And if i try to change the password with "usermod -p 'returned hash' user", it works, but i can't login anymore :-(
Are there any proposals?
Thanks for your help in advance.
Regards
daenu

public String createMD5HashCode(String text) throws
NoSuchAlgorithmException, NoSuchProviderException {
String result = text;
if (text != null) {
StringBuffer code = new StringBuffer(); //the hash
code
String plain = text;
byte bytes[] = plain.getBytes();You should realy specify the encoding here eg plain.getBytes("ASCII")
MessageDigest messageDigest =
MessageDigest.getInstance("MD5", "SUN");
messageDigest.update(bytes);This will add 'bytes' to the digest.
>
byte digest[] = messageDigest.digest(bytes); //createand this will add them again! You don't need the update.
code
System.out.println(digest.length);
for (int i = 0; i < digest.length; ++i) {
code.append(Integer.toHexString(0x0100 + (digest &
0x00FF)).substring(1));Very interesting! It took me some time to work out what this was doing!
result = code.toString();
return result;

Similar Messages

  • Java editor for Linux

    Which is the best java editor for Linux ??
    in the Win plataform I'm using the JCreator ... and now I'm migrating to the linux plataform...
    please tell me the name of the editor you are using if you use Linux... (Red Hat 7.1 here...)

    you can try SciTE from http://www.scintilla.org - it's simple, fast and good enough. you can work with java, c and many other programming languages. There are some features that don't present in any other editor.
    Btw SciTE is only editor, not complete IDE. If you wish a full IDE with projects.. etc you can use Borland's JBuilder

  • Why we have separate azure java SDK for linux and windows

    I saw different links for downloading azure java SDK for linux and windows.
    What difference does it actually have when java is platform independent? Or both are same jars?

    Hi,
    Thank you for your post.
    It contains the same jar files.
    Regards,
    Mekh.

  • DNSDHCP Java Console for Linux usage question

    Hi All,
    This should be one of the simplest things, but it defeats me. I have downloaded and installed the DNSDHCP Java Console for Linux on my SLED11 workstation. I start it up and am presented with a login screen:
    Server Address: [ ] Port: [ 636 ]
    (e.g. 192.168.xxx.xxx)
    Username: [ ]
    (e.g. cn=admin,o=companyname)
    Password: [ ]
    [v] Use SSL
    Questions:
    Server address: is that supposed to be my OES DNS/DHCP server? Or my eDir server? I've tried each.
    Username: is that supposed to be my tree admin? I've tried it.
    Password: I think I got this one.
    SSL: I *think* my server is set up for SSL, but I'm not sure. I've tried it both ways.
    I have tried every combination except the one that works. Can anyone suggest something that I may be missing?
    Thanks,
    Toney.

    Most of the time eDir servers default to SSL, and you have to check (or uncheck) the box under the LDAP Group object to require TLS authentication (or something like that)--so if you haven't done that then non-ssl will likely not work. I have had some boxes that wont do SSL though.... In that case, non-ssl usually works for me. You can also configure the same things under iManager.

  • Not able to see Java plugin for Linux RHEL 14.0.1

    I have installed Mozilla Firefox 14.0.1, for Linux, but I'm having trouble seeing the Java 'plugin' (libnpjp2.so').
    I believe I'm running Red Hat Enterprise Linux on a 32 bit machine, as detailed :-
    Linux localhost.127.0.0.1 2.6.18-128.el5PAE #1 SMP Wed Dec 17 12:02:33 EST 2008 i686 i686 i386 GNU/Linux
    I have installed the 32 bit version of Java :-
    [root@localhost /]# java -version
    java version "1.7.0_05"
    Java(TM) SE Runtime Environment (build 1.7.0_05-b06)
    Java HotSpot(TM) Server VM (build 23.1-b03, mixed mode)
    from the 'pluginreg.dat' file I see :-
    [INVALID]
    /root/Oracle/Middleware/jdk160_11/jre/lib/i386/libnpjp2.so:$
    I'm referencing the 'Oracle' version of 'libnpjp2.so', as this appears to be the 32 bit version,
    and I'm trying to configure Oracle APEX on this version of Linux.
    I think I need to run Firefox in 32 bit mode, but don't know how, or if what I'm attempting to do is possible ?
    Any feedback, would be most grateful.

    The regular Firefox version as downloaded from the Mozilla server is a 32bit version
    *Firefox 14.0.x: http://www.mozilla.org/en-US/firefox/all.html
    A 32 bit Firefox version only works with a 32 bit Java version and you need to place symlink to the Java plugin file (libnpjp2.so) in a location where Firefox finds it.
    Did you try to delete the pluginreg.dat file to force Firefox to create a new file?
    * http://kb.mozillazine.org/Determining_plugin_directory_on_Linux
    See Java Platform > Java SE 7U6 or Java 6U34 (Download JRE)
    *http://www.oracle.com/technetwork/java/javase/downloads/index.html

  • Free Java Installer for Linux & Solaris

    I use the NSIS Installer for my java application, but it works only on Windows.
    If you know a free installer which supports Linux or Solaris please send me an answer.
    Thank you.

    Java Web Start?

  • Free Personnal Java VM for Linux Familiar on ipaq H3800

    I would like to known if there is a free virtual machine and personnal profile to download for arm familiar linux on Ipaq H3800?
    Otherwise, I am interrested by speaking with someone that has always compiling the sun Personnal Profile source for this device and OS?
    Thank

    me too
    thanks

  • How to make installer of my java application for linux

    I want to make an installer for my java application, I am using Install any where trial version its create an installer but when i installed n execute it, it display that
    "unable to locate main class, class must be public n having a public static void main(....) LAX."
    while making the installer I specifically mention the main class.....
    I tried a lot but getting same error again n again,
    Any one has any idea, what went wrong or what should I do to make Installer by using any good tool.
    Thanks for every Thing.

    After making the installar using InstallAnywhere, when i run the installer it shows the following error....
    Unable to locate the application's 'main' class. The class 'wekna.gui.explorer.LoginScreen' must be public and have a 'public static void main(String[])' method. (LAX)
    Unable to Launch Java Application: Unable to locate the application's 'main' class. The class 'weka.gui.explorer.LoginScreen' must be public and have a 'public static void main(String[])' method. (LAX)
    my main class has syntax public static void main(...) because otherwise java will generate error,
    my application is running well with make file but I want to make an installer......

  • Java Comm for Linux

    I am getting this error 'isDevLink' when i call the method CommPortIdentifier.getPortIdentifiers();
    While the same method is working fine on windows, but there is this error on Linux. Minicom is also talking to the modem at /dev/ttyS0, but not Jave comm lib.
    Please let me know, if any one can help.
    Thanks.

    and what does this error message mean??
    The package was installed accordingly to "Java(tm) Communications API Linux Installation Instructions":
    $ls /usr/lib/libLinuxSerialParallel.so
    /usr/lib/libLinuxSerialParallel.so
    $env|grep CLASS
    CLASSPATH=<..skipped..>:/opt/commapi/jar/comm.jar:/opt/commapi/jar/commtest.jar
    $ ls /opt/jdk1.5.0_04/jre/lib/javax.comm.properties
    /opt/jdk1.5.0_04/jre/lib/javax.comm.properties
    What else does it need?

  • Java Editor in Linux

    hi all,
    can someone suggest a good Java Editor for Linux? I'm currently using the BlueFish Editor and i press the DOT nothing is come out, i hope that to get an editor where the members can come out after the dot is presses. By doing this, it will minimise a lot of typing error. I had try to install the JCreator on my system, but the setup cannot run on Linux.

    u mean just copy the installation to the
    /usr/local??
    Because i dun have the root permission and the
    installation file has been downloaded at the desktopIf you don't have root permissions (and can't get them) then you probably will not be able to copy the JDK to /usr/local . You don't need the JDK to be anywhere in particular so if it is installed in your home directory then leave it there. Just make sure your 'path' is set correctly!
    To check you have it configured right, use
    java -version
    and it should report
    java version "1.5.0_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
    Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

  • Best Java IDE fo Linux

    what is the best Java IDE for linux system

    I use on three different projects three different IDEs: JBuilder, Eclipse and IntelliJ. I personally prefer IntelliJ, although Eclipse and JBuilder are very good products as well. If you need absolute stability, Eclipse is maybe a little bit early in development, on the other hand it is free and open source. Additionally it "feels" a little bit faster on Linux, because it does not use Swing but SWT which utilizes native controls.
    ~k

  • Java EE 5.0 for LINUX vs. Windows

    Hello,
    I am beginner. Just to be sure I would like to ask whether JAVA EE 5.0 specification is fully implemeted for LINUX as well as for Windows. I need to be sure that if I will create some JAVA EE application and I will tun it on Glassfish AS on Windows that it will work the same way on Glassfish server running on LINUX. Will the same application run the same way or are there any known differences or holes?
    Thanks

    I'm no expert on Glassfish. However I would expect the server to behave the same on the two OS's. But that's in terms of functionality - apart from clustering. Performance is a different matter.
    Some things to consider:
    On your PC you're running one server-instance - is the server clustered in production. So beware of the parallel issues.
    PC's have nice fast CPU's - your server will most probably have several but slower CPUs. So tuning may be different, but depend on results in development. Further theres the network - if you're running with a local database. But the server you're deploying to is seperate from the database - then you have to take that into account.
    In short, if you're acareful in following the JEE specifications, then the server will act as on your PC. Regarding performance: sure you can tune many things, most of all algorithms, database queries and so on. But you can't rely on your local results. If you have specific requirements on response-time - you have to test in an environment identical to (or close enough to) the Production environment.
    Hope this helps,
    Michael Willer

  • Availability of Java Wireless Toolkit (J2ME) for linux

    Hi, Could anyone tell me when will be available the Java wireless toolkit for Linux again ?
    According to download page is offline since March 20
    Sun Java Wireless Toolkit for CLDC 2.5.2 ML
    - March 20, 2012 - This download is being updated and will be made available again shortly, please check back regularly for it's availability.
    Is there any other way to download the Linux API for mobility development ?
    Thanks in advance.

    The link is back up.

  • Error in the latest Java comm api for Linux

    installed latest Java comm api for Linux, tried test application for the Sun package:
    $ java SimpleRead
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at SimpleRead.main(SimpleRead.java:67)
    Caused by: java.lang.NullPointerException
    at javax.comm.CommPortIdentifier.findConfFile(CommPortIdentifier.java:199)
    at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:117)
    ... 1 more
    What deis this message mean? How to make you serial port support work?

    and what does this error message mean??
    The package was installed accordingly to "Java(tm) Communications API Linux Installation Instructions":
    $ls /usr/lib/libLinuxSerialParallel.so
    /usr/lib/libLinuxSerialParallel.so
    $env|grep CLASS
    CLASSPATH=<..skipped..>:/opt/commapi/jar/comm.jar:/opt/commapi/jar/commtest.jar
    $ ls /opt/jdk1.5.0_04/jre/lib/javax.comm.properties
    /opt/jdk1.5.0_04/jre/lib/javax.comm.properties
    What else does it need?

  • Is there any plan to release Java ME SDK 3.0 for linux?

    Hi
    Thank you for reading my post.
    Can someone please let me know when will Sun release Java ME SDK for linux?
    Thanks

    Note: This thread was originally posted in the [Sun Java Wireless Toolkit|http://forums.sun.com/forum.jspa?forumID=82] forum, but moved to this forum for closer topic alignment.

Maybe you are looking for