String to MD5 hex

hi all, i need a way to convert a String to an MD5, to be more precise i need to get the MD5 string in hex. I have tried a few methods but they only seem to work 80% of the time, any help would be appriciated.
note: i am storing values in a mysql db (just a test will try SHA later) when i put the data in the my sql i pass it as a string using MD5("myString")
thanks

Well i got it and it works perfectly in case any wants to now this is the code
import java.security.MessageDigest;
public class MD5Maker
     public static String makeMD5(String str){
          String MD5HexString = null;
          try{
             byte[] intext = str.getBytes();
             StringBuffer buf = new StringBuffer();
             MessageDigest md5 = MessageDigest.getInstance("MD5");
             byte[] md5bytes = md5.digest(intext);
             for( int i = 0 ; i < md5bytes.length ; i++ ) {
                   int value = 0xff & ((int)md5bytes);
               if (value < 16)
                    buf.append("0");
               buf.append(Integer.toHexString(value));
               MD5HexString = buf.toString();
          catch (Exception e) {}
          return MD5HexString;

Similar Messages

  • SOA 10g - Convert string to MD5 hash

    Hi Guys,
    Is there a way apart from using Java to convert a string to MD5 hash in soa bpel process ?
    Thanks
    K

    Sorted it out, used java embedding and it worked, example below of java embedding
    String md5=getVariableData("md5Var").toString(); //this is the variable that needs to be md5 hashed
    try{              
    MessageDigest md = MessageDigest.getInstance("MD5");
    byte[] myByteArray1 = md5.getBytes("UTF-8");
    byte[] myByteArray2 = md.digest(myByteArray1);
    BigInteger bigInt = new BigInteger( 1, myByteArray2);
    String javahashedstring = bigInt.toString(16);
    setVariableData("md5Var", javahashedstring, false); //return md5 hashed variable
    }catch (Exception ex){     
    ex.printStackTrace();
    }

  • Encrypting String with MD5, then storing as String

    Hello.
    I believe I have a way to do this but I want to verify that:
    1) It is doing the action that I want
    2) There is no easier/simpler way with less lines
    What I am looking to do is take a String that is passed to the method, encrypt it using MD5 algorithm, and then store the result back into String form.
    In the following code encyptedPassword is the String to-be encrypted and this.encryptedPassword is the String for where I would like to save the result.
    try
                MessageDigest md=MessageDigest.getInstance("MD5");
                md.reset();
                md.update(encryptedPassword.getBytes());
                byte raw[]=md.digest();
                for(int x=0; x<raw.length;x++)
                    this.encryptedPassword+=(char)raw[x];
            catch(NoSuchAlgorithmException e)
                e.printStackTrace();
            }

    You will have to hex-encode or base-64-encode the encrypted data. String is not a container for binary data, and encrypted data is binary data.

  • Replace hex character in a string with another hex character

    Hi Guys,
    Heres a problem scenario, hex character 92 looks very much like hex character 27 (apostrophe).
    I need to write a program that can replace all hex character 92 to hex 27 in a string.
    Being a novice on the regular expressions, I would appreciate if somebody can show
    the exact syntax to to perform this replacement.
    Many Thanks
    -Anil

    I don't think you need to use regex to do this:
    String s = something();
    char a = 0x27;
    char b = 0x92;
    s.replace(a,b);
    And don't forget that since Strings are immutable you need:
    s = s.replace(a,b);to do anything useful.

  • Turn a string that shows hex data in normal format, into a string that shows the same data in hex format

    I have a string of arbitrary length - say, 1AB1C0 - in normal format. I would like to have a function which takes that string in, and outputs the same exact characters, but in hex format. So the input will read 1AB1C0 in normal string format, and the output will read 1AB1C0 in hex string format.
    I am doing this because I have found the end device works better if I send the bytes as a hex string vs. as an array of U8. Furthermore, I manipulate a lot of byte streams in my program, and I find the string parsing tools less cumbersome to use vs. the byte array parsing tools - however, they only work on the strings as they appear in normal mode. So I have reasons in different parts of my program to have the string in normal vs. hex formats; but I cannot figure out any remotely elegant way to cast from one to the other.
    Solved!
    Go to Solution.

    CraigRem wrote:
    So the input will read 1AB1C0 in normal string format, and the output will read 1AB1C0 in hex string format.
    Well, you need to scan the hex formatted string two bytes at a time to an U8 numeric and then cast it back to a string. There are many ways to do that, here are two possibilities. (Mkae sure to use the correct representations as labeled).
    (I still don't quite understand your reasoning why you need this).
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    NormalToHex1.png ‏12 KB

  • Hex String to 'Ascii Hex' String!

    I am having a mental block and wonder if someone can help!!
    I am reading a serial device and getting a hex string back. I need to display this hex string to the operator within a pop-up box (PDA). The Message box will obviously contain normal text with the HEX code appended to the bottom.
    When I run the code the pop-up box displays the legible message to the user but the HEX string returned appears in the appropriatte ascii characters (because the pop-up displays normal string).
    My question is, how to make an hex string appear within a normal display string indicator 'the same' as it appears in its Hex display indicator:
    0x0A1C - Hex display needs to appear as 0A1C in normal display string indicator.
    Thanks in advance
    ssk
    Solved!
    Go to Solution.

    See picture.
    Message Edited by andre.buurman@carya on 04-08-2009 12:41 PM
    Regards,
    André
    Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)
    Attachments:
    Hex string to normal string.png ‏4 KB

  • Normal string display to Hex string display

    Hi all
    i like to convert a normal strijng display which contains alphanumeric strings to hex format
    String length will be of 25 characters which will be read through bar code reader
    Could someone help me in solving this
    Thanks
    Bala

    Hi smercurio_fc
    Thanks for the vi. i tried the method which you have sent me.
    So i cant transfer 'S' through serial port?
    Is there any other way to transmit this through Serial port.
    Also i need another clarification
    A sub vi is running inside my main vi and i need to stop/pause the sub vi from the main vi front panel. how could i can stop the sub vi?
    Thanks and regards
    Bala

  • Question about string constant in Hex display format

    how to get a plus of 2 string constant which is display in Hex display like attahced, for example I have string "28" and "5D" in Labview which has been in Hex format, the plus of this 2 string should be "85" in Hex. pls help on this, thanks
    Attachments:
    1.jpg ‏21 KB

    This'll work, too.  I'm afraid of casting types...
    Jm
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
    Attachments:
    hex.png ‏2 KB
    hex.vi ‏7 KB

  • Generating Random Alpha numeric Salt String using MD5 or other algorithm

    Hello,
    I have a requirement where i need to generate a random alpha numeric salt for MD5 algorithm. Is there a best way to generate this salt ?
    The alpha numerics should confine to 5 digits with possible values for each digit being (a-z), (0-9), (A-Z).
    Any good random generator for salt would be appreciated.
    Thanks.

    Hi there,
    I think the book you read is the book "Java Security", I have that one too.
    Please read all those pages before this code.........
    In this code, it used the RSA algorithm to do the encryption and JDK DOES NOT support
    RSA algorithm....
    Beside, this line
    KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA", "BC");It implies the BouncyCastle security provider is in use.... so
    www.bouncycastle.org might be a good place to start with....
    Good luck!

  • Converting a hex String to its corresponding hex value...?

    Yeah, I'm having quite a bit of fun guessing this one... :p
    I have a string of n characters and have used Integer.toHexString( ( int )str.charAt( i ) ) to convert each character to a string representing its hex value. Now I need to USE that value for bit-wise operations, like, say, applying the AND, OR, etc. operators...
    Example:
    hexvalue &= 0xC000FFFF; //the second value is the one extracted from the string;
    How can achieve this...? Any help is greatly appreciated... :}

    Since a Java char is numerically a Java short, you can apply bitwise operators to chars directly - the conversion to hex simply changes the way that the char is viewed; the result can also be viewed as a number in other bases.
    For instance, the char 'A' can be also be represented as any of the following values:
    binary - 1000001
    octal - 101
    decimal - 65
    hex - 41
    Likewise, 'Z' can also be viewed as
    binary - 1011010
    octal - 132
    decimal - 90
    hex - 5A
    "Anding" the letter 'A' with 'Z' ('A' & 'Z') or doing the same using any of the other representations will result in (binary 1000000, octal 100, decimal 64, or hex 40) - the bit pattern is the same, only the representation of the result varies.

  • How to use MD5 format of string

    i want to change a password string to md5 format
    how can i do it

    http://www.twmacinta.com/myjava/fast_md5.php

  • How can I write this string to a file as the ASCII representation in Hex format?

    I need to convert a number ( say 16000 ) to Hex string ( say 803E = 16,000) and send it using Visa Serial with the string control in Hex Mode. I have no problem with the conversion (see attached). My full command in the hex display must read AA00 2380 3E...
    I can easily get the string together when in Normal mode to read AA0023803E... but how can I get this to hex mode without converting? (i.e. 4141 3030 3233 3830 3345 3030 3030 3031 )
    Attachments:
    volt to HEX.vi ‏32 KB

    Sorry, The little endian option was probably introduced in 8.0 (?).
    In this special case it's simple, just reverse the string before concatenating with the rest.
    It should be in the string palette, probably under "additional string functions".
    (note that this only works in this special case flattening a single number as we do here. If the stat structure is more complex (array, cluster, etc.) you would need to do a bit more work.
    Actually, you might just use typecast as follows. Same difference.
    I only used the flatten operation because of the little endian option in my version.
    Message Edited by altenbach on 11-16-2007 11:53 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    littleendian71.png ‏4 KB
    littleEndiancast71.png ‏4 KB

  • I want to communicate a RS485/2-wire device through COM1. I tried Instrument I/O Assistance to write to COM1(hex string with or without end bye:0D0A), something happened on the bus, but is not defirrential signal, and device didn't recognised them.

    I am new to LabView, so please bear with me...
    I tried to communicate with an RS485/2-wire device through COM1.  I used Instrument I/O Assistant (and Advanced/Basic Serial Write and Read examples) to write command (HEX string) to COM1,  
    tried writing HEX strings with and withour end bye (is 0D0A the correct end signal for HEX string?).  Both didn't get device's responce.  Looks like the device didn't recognize the command.
    I monitored the transmitted signals on the bus, they were not differential as supposed to be.....
    What is the possible reason to cause this? Please help...
    The hardware connection is OK, because I am able to communicate with the device through COM1 (with the same command) using different software application.

    How are you sending the hex? Is your string control set for hex display or normal? If it's set for normal, then if you send something like 'AD', then you aer sending the ASCII characters 'A' and 'D' and that's not the same thing. I don't believe the I/O assistant can send hex but you can modify the basic serial write and read to do so. Just right click on the string control and select 'Hex Display'. You can also enter the data in a numeric control (set for dex display) and use a type cast or an array of U8's and use the Byte Array to String function. Hex data usually doesn't use any kind of termination characters such as CR/LF.
    If communication is working with another app, then as you said, the hardware is okay and it's not a problem with differential signaling.

  • Find logo from binary or hex string

    HI All ,
    I have file 2 strings one with HEX and one binary this to string is contain the value
    for attachment (logo) ,which FM or method i should use to see the logo, the picture itself  ?
    Regards
    James
    Edited by: James Herb on Feb 28, 2010 5:32 PM

    Hi James,
    This methods and function modules should work for you.
          CALL METHOD cl_binary_relation=>read_links_of_binrel
            EXPORTING
              is_object   = is_object
              ip_relation = 'ATTA'
            IMPORTING
              et_links    = et_links.
        catch
        cx_obl_parameter_error into icx_obl_parameter_error.
          exception_string = icx_obl_parameter_error->get_longtext( ).
        catch cx_obl_internal_error into icx_obl_internal_error .
          exception_string = icx_obl_internal_error->get_longtext( ).
        catch
        cx_obl_model_error into icx_obl_model_error.
          exception_string = icx_obl_model_error->get_longtext( ).
      ENDTRY.
      SORT et_links BY utctime.
      LOOP AT et_links INTO et_links_s.
        v_tbx       = sy-tabix.
        document_id = et_links_s-instid_b.
        CALL FUNCTION 'SO_DOCUMENT_READ_API1'
          EXPORTING
            DOCUMENT_ID                      = document_id
          FILTER                           = 'X '
         IMPORTING
            DOCUMENT_DATA                    = document_data
         TABLES
            OBJECT_HEADER                    = object_header
            OBJECT_CONTENT                   = object_content
          OBJECT_PARA                      =
          OBJECT_PARB                      =
          ATTACHMENT_LIST                  =
          RECEIVER_LIST                    =
          CONTENTS_HEX                     =
         EXCEPTIONS
            DOCUMENT_ID_NOT_EXIST            = 1
            OPERATION_NO_AUTHORIZATION       = 2
            X_ERROR                          = 3
            OTHERS                           = 4.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    ENDLOOP.

  • MD5 ?

    hi,guys.....
    how to convert string to md5 ? and how to convert from md5 to string ?

    how to convert string to md5 ? Somethng along the lines of
               String dataToHash = "Hello World";
                MessageDigest md5Actor = MessageDigest.getInstance("MD5", "SUN");
                byte[] md5digest = md5Actor.digest(dataToHash.getBytes("utf-8"));but you may well need to Hex or Base64 encode the resultant md5digest byte array.
    and how to convert
    from md5 to string ?Assuming that you mean "how can I get back the original string given an md5 digest?" - this cannot be done since md5 is a hash and not an encryption.

Maybe you are looking for

  • Error when importing music CD into iTunes

    I am trying to import an audio CD to iTunes. I have a (newish) macbook air using OSX 10.9.3, so I am using a Samsung Portable DVD Writer (SE-208). iTunes can play the music file from the cd, but when I try to import a track/cd I get the following err

  • Select columns from table for display in alvgrid.

    Hi all, i have the following: i do select a tablename and pass it as a parameter. then this table is loaded into an internal table and displayed in an alv-grid. what i now want to do is a step  between the both: after the internal table with its stru

  • Cannot open standby database in read only....

    i do the following procedure on my standby database ORACLE 9.2.0.7 SQL> startup nomount ORACLE instance started. Total System Global Area 538412112 bytes Fixed Size 742480 bytes Variable Size 402653184 bytes Database Buffers 134217728 bytes Redo Buff

  • Urgent - alvs-MAXFORUMPOINTS

    1.     REUSE_ALV_VARIANT_DEFAULT_GET 2.     REUSE_ALV_VARIANT_F4 3.     REUSE_ALV_VARIANT_EXISTENCE 4.     REUSE_ALV_EVENTS_GET 5.     REUSE_ALV_COMMENTARY_WRITE 6.   REUSE_ALV_FIELDCATALOG_MERGE 7.   REUSE_ALV_LIST_DISPLAY 8.     REUSE_ALV_GRID_DISP

  • Material used in Z30 leather holster

    Hi, I need to know the type of leather used in the Z30 holster i.e. real or synthetic, and from which animal.  Where can I find this information? Thanks.