String encryption problem

Hallo,
I need to encrypt password with MD5 algorithm. I'm using following method:
public static byte[] encryptStr(byte[] chars){
MessageDigest digest=null;
try {
digest = MessageDigest.getInstance("MD5");
digest.reset();
digest.update(chars);
return digest.digest();
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(RzJUtils.class.getName()).log(Level.SEVERE, null, ex);
return null;
My application communicates with a servlet, so I have to send encrypted password to serwlet. But if I use the method in sending desktop application I get as encryption result following string: � �o,H�0�3�
�
If I use the same method serverside (in servlet) I get following string: — •o,Hćş0Đ3 
Î
I've tried with convertion between different charsets but without success. Why are the results different? Is there a way to get eqaul results in desktop application and in servlet?
with regards
Rafal Ziolkowski

Of course, what you get isn't a String at all, it's a byte array. If you want to display it I suggest you do so in hex. You can do this easily enough with something like:
private String toHex(byte[] bytes) {
   StringBuilder sb = new StringBuilder(bytes.length * 2);
   for (byte b : bytes)
        sb.append(String.format("%02x" b & 255);
   return sb,toString();
}That gets rid of problems w.r.t character encoding (at least, of the digest).
Incidentally it's confusing to call a digest "encryption".

Similar Messages

  • Encryption problem caused by Adobe?

    Dear All,
    I am a video editor and exchange files with my collaborator via the cloud, but not via Adobe Cloud which does not allow .mp4 files to be sent due to copyright problems.  My cloud service is not allowing my collaborator to view my latest .mp4 file created by Adobe Premiere Pro 2014, stating that the file is encrypted.  I think this encryption problem is being caused by my cloud service, but I'm wondering if Adobe Premiere has inadvertently written any copyright encryption into this file that I'm not aware of.  This becomes very frustrating when you're trying to collaborate on a video of your own creation!  Thanks for your help.
    Small Town Gal

    Dear John,
    I tried the zip file, but it still could not be opened on the other end -- same error message.  Thanks.

  • I'm getting 100s of debug.log. files on my macbook OS 10.7.5. I've never seen them before. Should I be worried? They look like this: debug.log.100100_100119.sent. Is it an encryption problem? thanks for any help!

    I'm getting 100s of debug.log. files on my macbook OS 10.7.5. I've never seen them before. Should I be worried? They look like this: debug.log.100100_100119.sent. Is it an encryption problem? thanks for any help!

    I'm getting 100s of debug.log. files on my macbook OS 10.7.5. I've never seen them before. Should I be worried? They look like this: debug.log.100100_100119.sent. Is it an encryption problem? thanks for any help!

  • Simple String Encryption

    HI,
    I have been serching around on here for encyption methods but there seems to be soo many i not sure which ones would be good for me.
    All i want to do is encypt and decrypt a String record. The encryption doesnt have to be particulary safe but must work for all possible charaters. Basically i am saving records to a text file and i dont want someone to be able to open the text file and read the contents.
    I would like to make it as simple as possible so i can just use it like:
    String record = "This is the record";
    // Encrypted Record
    String encRecord = Encryption.encrypt(record);
    // Decripted Record
    String decRecord = Encryption.decrypt(record);Can anyone stear me in the right direction or give me some sample code i can study.
    Thank you in advance
    ed

    Here is simple encryption routine that I just wrote that I bet would keep someone
    stumped for a while.
    * This is a simple encryption class that uses simple character substitution.
    * To keep the pattern from being obvious the shift factor is a function of the current character's
    * position in the source string. This makes sure that all letters aren't encrypted to the same value.
    * Usage: To encrypt a string just pass it to the encrypt method.
    *         String encryptedString = Encryptor.encrypt("Some string.");
    *        To decrypt a string just pass the encrypted string to the decrypt method.
    *         String decryptedString = Encryptor.decrypt(encryptedString);
    class Encryptor
      static final byte [] shiftFactor = {2,5,7,9,13,17,19};
      static final int modulo = shiftFactor.length;
      static public String encrypt(String s)
         char [] ba = s.toCharArray();
         for (int i = 0; i < ba.length; i++)
              ba[i] += shiftFactor[i%modulo];
        return new String(ba);
      static public String decrypt(String s)
         char [] ba = s.toCharArray();
         for (int i = 0; i < ba.length; i++)
              ba[i] -= shiftFactor[i%modulo];
         return new String(ba);
      public static void main(String [] args)
         String [] test = {"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz,./<>?;':\"[]{}-=_+!@#$%^&*()`~",
                           "Now is the time for all good men \n to come to the aid of their country."};
        for (int i = 0; i < test.length; i++)
              System.out.println(test);
              String encrypted = Encryptor.encrypt(test[i]);
              System.out.println(encrypted);
              System.out.println(Encryptor.decrypt(encrypted) + "\n");

  • AEGE wireless encryption problem

    I recently bought an AE GE wich I received last week. When configured first time it was upgraded with 7.2.1 firmware, also my MBP was upgraded with latest Airport Utility 5.2.1. Connected to my AEGE I have 1 MBP, 1 AppleTV, 2 Fujitsu-Siemens Vista laptops through wireless and 1 sippura, 1 dreambox and one Oki C3200n wired. I also have a USB HD connected. Everything was great until the morning of the 5th day. Waking up my MBP I got connected to my WPA/WPA2 WLAN, but I only got a 169.x.x.x IP address. I checked the Vista computers, the same issue there, no DHCP only a 169.x.x.x address. AppleTV no IP at all. If I manually configure the computers with a IP address, some packets goes through, but the packet loss is huge.
    Whatever combination of encryption used and channel selected, the AEGE is unusable. Using no encryption on the wlan gives me normal behaviour. Right now I have downgraded to 7.2 but the issues remains. Hardware error or a software problem?

    Jeanna
    Panther will work wirelessly using encryption. You are probably just not setting it up right.
    +(powerbook G4 10.3)+
    http://discussions.apple.com/thread.jspa?threadID=1797218&tstart=0
    +(a detailed response from Tesserax)+
    http://discussions.apple.com/thread.jspa?messageID=8661356&#8661356
    As I said, repost your question over in the Airport forum, I don't know enough about the ins and outs of your encryption problem to help you.
    Sorry I couldn't be of more help.
    regards roam

  • Help:String arg[ ] problems

    Hi:
    I am having problems with my encryption program and I want to check that the contents at the command line a being read properly.
    ex: java Monoalphabet -k feather in.txt out.txt
    -k(indicates encryption)
    feather(keyword)
    How do I check to make sure that the input in being read into String args[]properly?
    Thanks.

    Print the args out using System.out.println() in a loop at the beginning of your main method.

  • Java card Applet RSA encryption Problems with Android

    hi all,I am new to java card development. I have used nxp jcop 31-36 java card and nexus s for testing the application.so i have faced lot of problems.first of all i want to encrypt data coming from the android app using RSA1024 and send back to the android application.there are the problems I faced
    1.RSA1024 and RSA2048 algorithms can't work with the nexus s Application.it means i can't receive any encrypt data from card.but when i test the application with eclipse jcop shell tool it is work properly.
    2.when i run the application in nexus s the application is crashed.it gives some wired sound when tap the java card to android phone.it may be java card application crashed or give some wired sound from android OS level.
    3.Then I Test the Application with Samsung S2. Sometimes it works but sometimes it crashed.in the S2 the encryption works fine(but we have to keep wile card 2 or 3 minutes).
    these are the steps i followed in established the connection i android phone.So fist i created the ISO dep connection and first select the Application(00A40400AID).Then using transive method i send data to java card.In the Java card in the installation i have created the RSA key pairs and get the RSA public key and private key.in some method i got the APDU buffer and read data and encrypt this data.Then those are send back to the card. First i want to know is there any problem in Android Os or JCOP 31/36 card.And other thing each time i requested to java crd is that need to reset the java card and how to reset the Java card.(some brief idea)

    Hi,
    1) Import android.smartcard libraries,
    2) Try to make a connection :
    ISmartcardConnectionListener connectionListener = new ISmartcardConnectionListener()3) create an instance of smartcardclient:
    smartcard = new SmartcardClient(this, connectionListener);4) get the list of readers :
    String[] readers = smartcard.getReaders();you can check if a specific reader is connected or nor with
    smartcard.isCardPresent(readers [0]);5) create a card channel and select your applet:
    cardChannel = smartcard.openLogicalChannel(cardReader, APPLET_AID);
    ICardChannel cardChannel = null;
    cardChannel = smartcard.openLogicalChannel(cardReader, APPLET_AID);6) you can send and receive APDUs with this line of code:
    byte[] response Apdu = cardChannel.transmit(commandApdu);Regards,
    Hana

  • Setting input fields to an empty string BIG PROBLEM

    Hi Rob, thanks for your rerply, It makes sense alright, but I am using 2 seperate input fields. I have discovered what is causing the problem .
    After the user types into the inputfield and moves on to a different frame, I have set the input field to an empty string and this is what is causing the problem.
    I have tried setting the input field to an empty string in a movie script and on individual sprites and the first right answer is not excepted.I have to type in the right answer twice to get get a right response. I am actually using three seperate input fields in total, each with a different name and behavior. Even If I use one input field I still have the same problem. Its driving me crazey. Any Ideas.
    Anne

    I believe that the FIM Service always does trims on string, so you may be out of luck.
    What is your scenario / what are you trying to accomplish by setting a space in an attribute? A space is not an empty string in my definition.
    Regards, Soren Granfeldt
    blog is at http://blog.goverco.com | facebook https://www.facebook.com/TheIdentityManagementExplorer | twitter at https://twitter.com/#!/MrGranfeldt

  • String concat PROBLEM??? Please Help

    I have this strange Question regarding String concat
    If I say:
    String str = "Welcome";
    str.concat(" to Java");
    System.out.println(str);
    The output is: Welcome.
    How do I get the output to Welcome to Java??

    I have this strange Question regarding String concat
    If I say:
    String str = "Welcome";
    str.concat(" to Java");
    System.out.println(str);
    The output is: Welcome.
    How do I get the output to Welcome to Java??
    The problem is that String is immutable, The String you have held in str does not change, rather a new Srtring is returned. So all yo have to do is grab the new String
    str = str.concat("to Java");
    or use the new String without keeping it.
    ie
    System.out.println(str.concat("to Java"));

  • String concat problem

    Hi folks,-
    i know this question might be very simple but i just cannot see what i am doing wrong here.
    String stringA, stringB, stringC;
    stringA= new String();
    stringB= new String();
    stringC= new String();
    stringA = null;
    stringB = "TRUE";
    stringC = "Error:";
    stringA.concat(stringB); // my code stops and quits here w/o error
    // other codewhat is wrong here?
    thanks much

    could you then please explain the following?
    public String concat(String str)Concatenates the
    specified string to the end of this string.
    If the length of the argument string is 0, thenthis
    String object is returned. Otherwise, a new String
    object is created, representing a charactersequence
    that is the concatenation of the charactersequence
    represented by this String object and thecharacter
    sequence represented by the argument string.
    Examples:
    "cares".concat("s") returns "caress"
    "to".concat("get").concat("her") returns"together"
    Parameters:
    tr - the String that is concatenated to the end of
    this String.
    Returns:
    a string that represents the concatenation of this
    object's characters followed by the stringargument's
    characters.
    Throws:
    NullPointerException - if str is null.It returns a new String, which you are
    throwing away. Change your code like this:
    stringA = stringA.concat(stringB);
    and then you'd get somewhere.yes, it makes sense but the description does not say this.
    i think that will work but my problem is with the description of this
    concat operation on the java web site.
    thanks for the help

  • String check problem

    I have a doozy of a problem on my hands. My company has introduced a password policy that every user must me now. Some of my criteria is that a password must contain at least one symbol and at least one number. In 10g I can use REGEXP_LIKE function, but I am running 9i. I have tried to use translate, OWA_PATTERN function, everthing. How can I take a string variable, and test to see if there is a symbol in the text or a number. I want to be able to return a true/false value?
    Please advise?

    Like Kamal says, use built-in functionality FIRST.
    Failing that, presumably you would write something like this (I forget the exact naming standard for the password verify function).
    CREATE FUNCTION valid_password (
       p_password IN VARCHAR2)
       RETURN BOOLEAN
    IS
       FUNCTION contains_at_least_one (
          p_string IN VARCHAR2,
          p_characters IN VARCHAR2)
          RETURN BOOLEAN
       IS
       BEGIN
          RETURN LENGTH (TRANSLATE (p_string, 'X' ||
            p_characters, 'X')) < LENGTH (p_string);
       END;
    BEGIN
       RETURN contains_at_least_one (p_password, '0123456789')
          AND contains_at_least_one (p_password, '!£$%^&*(){}~@??|<>');
    END;

  • String overlapping problem in mx:List caused by wordWrap

    I'm using mx:List to display String items. The dataProvider is XMLListCollection. Some of the String is long so it takes more than one rows. I use the wordWrap to display the long String in more than one rows. The problem is that the next String item will overlapping with the long String. The mx:List can not adjust the vertical space for the Strings that needs more than one rows dynamically. Any suggections?

    Here is solution: variableRowHeight="true"

  • String offset problem

    Hi,
    I'm using 1.4.2 at the moment.
    I got the problem below and have no idea how to solve it. The program portion is:
    String x = node.getText();
    The node.getText() should contain value = "\n\r"
    However, it always return me "\r" only.
    I checked with the debugger and found that when I change the offset value of x to 0, it can return me "\n". However, the original offset value is always kept as 1. That's the reason why it always return me "\r".
    Can anyone help and tell me how to get the value "\n" in this case, i.e. any String method which I can check and get the offset value 0 from the string x.
    Thanks million in advance.
    Regards,
    Eric

    Can anyone help and tell me how to get the value "\n"
    in this case, i.e. any String method which I can
    check and get the offset value 0 from the string x.
    x.charAt(0);is probably what you mean.

  • String item problem

    I use mobility pack visual designer.
    When I create a string item in visual screen designer it looks like that:
    Title
    <text>
    but after i run my app it looks different
    Title <text>
    Why there's no line break?
    When I try to add the line break manually it doesn�t work because screen designer property editor adds to the code \\n when I put \n
    so generated code looks like that
    stringItem1 = new StringItem("stringItem1\\n", "<Enter Text>");  and I cannot edit it manually because generated code is blocked by net beans
    I can initialize my stringItem object one again
    stringItem2 = new StringItem("stringItem2\n", "<Enter Text>");  but I thing that�s very stupid to reinitialize an object twice
    And the line break after title doesn't solve my problem because if the title is too long the device will automatically brake the line and I�ll get this
    A long long title........
    <text>
    one empty line because of that break
    Any ideas?
    I don�t want to use textField because when you set it to uneditable its color becomes gray.

    Check the actual URL up in the location bar. Your comma may actually be dropping out there, because it isn't encoded such that in value commas can be differentiated from delimiters, so the fields aren't lining up in the URL properly.
    When you go to a page that takes in parameters for assignment in the link, it has 2 fields. The first is the comma separated list of the item names on the page to assign, which wouldn't contain commas in their names. The other field in the URL is a comma separated list of values to be assigned to the previous list. Since these values aren't encoded, the comma in the value is picked up as delimiter and not a part of the value. I have an example I can load up to apex.oracle.com if you need.
    -Richard
    Edited by: rwendel on Aug 13, 2009 11:51 AM

  • Passing string data problem

    Dear readers,
    I came across some problem in my labview VI where I try to pass a string (stored in a local variable) to other string variables connected to that local variable. In this case, I have a local string variable called 'output_string1', which contains the string '123'. I have it set to 'write'. Then I connect 3 string Indicators to this local variable, called 'string1', 'string2', and 'string3'. I would expect these connected string indicators to also contain the string '123', as they're simply connected to the 'output_string1'. But the strange thing is that only 'string2', and 'string3' contains '123', but 'string1' contains a '.' (ie a dot). Would someone be able to provide some kind advice about what I might be doing wro
    ng to get this result? I've attached the vi that I was making that demonstrates what I described. Thank you very much for your help.
    Attachments:
    remove_trailing_zeros_subvi.vi ‏78 KB

    In the last sequence you have intended to concatinate a string from three inputs; the local variable before, a "." and a local of string1. BUT instead of reading the local of string1 you have it in write mode...and the "." is wired into it! So you really wire 123 to that indicator as well in sequence 5, but it is immediately overwritten by a "." in the next sequence.
    That aside though there's two other things about the code that needs to be commented:
    a) You use locals as you would use them if G was a textual language; like variables. In G though we try to avoid locals all together, in G the wire is the variable! The wire in addition ensures the next thing the code lacks; execution control.
    b) Instead of sequences, use data flow. By working
    with the wire instead of locals you can ensure that things execute in the order you want it to, without the need for a sequence structure. And without a sequence structure the code becomes much easier to read and maintain.
    I have attached a modified version of your code that applies these two conversions to a "G" way of programming.
    Removing trailing zeroes can be done much easier though, attached is also an example of one such way.
    MTO
    Attachments:
    remove_trailing_zeros_Simplified.vi ‏45 KB
    remove_trailing_zeros_improved.vi ‏22 KB

Maybe you are looking for

  • How to convert Chineese script O/P into PDF?

    Hi, I have a requirement like "Irrespective of login language i need to send both english as well as chineese PDF's to multiple recepients.I m using CONVERT_OTF FM to do so.So when i login into EN and run the script english PDF comes fine but in chin

  • IPod Mini need help!

    Hello everybody! Lately, I have been having trouble with my pink iPod Mini (1st generation). I was updating my iPod Mini with the latest restore, and it completed, and required me to plug the ipod into an external power charger. I was not at home, an

  • How do I add/remove a contact to a mail GROUP in mac mail?

    Please help - thanks!

  • Please help!!! WRT54G lost after a reboot

    I have 2 laptops and both have always been hooked to my wireless network in my house. I had a system crash and I had to reboot windows xp home (teenage son found out about the Trojan virus the hard way) and now I cant seem to get my computer to find

  • HOW TO KEEP 3 LINES IN SELECTION-SCREEN

    hi all, i have a requirement. i have to keep one field in selection-screen say v_text whose length is 70 characters . and i have to display text as follows <System Date> ': EST STATUS:HUNGARY PROJECT:' in form of 3 lines by default. any one can send