Ismael Blesa Part wrote:
> 
> Hi all,
> 
> I am trying to cipher some of the parameters that are sent to my
> application Server. I am having some problems with the conversion from
> String to an array of bytes. Sometimes the conversion losts info.
> Have any of you already solved this issue.

I'm not using a cipher, but a simple MD5 hash:
  private void addAssinatura(){
    try{
      MessageDigest md = MessageDigest.getInstance("MD5");
      char[] chtext = text.toCharArray();
      byte[] bytes = new byte[chtext.length];
      for (int i = 0; i < chtext.length; i++){
        bytes[i] = (byte)chtext[i];
      }
      md.update(bytes);
      String sign = "";
      byte[] digest = md.digest();
      for (int i = 0; i < digest.length; i++){
        sign += String.valueOf(digest[i]);
      }
      text += "Assinatura: " + sign;
      this.key = sign;
    } catch (Exception ex){
      text += "Erro interno. Não foi possivel assinar texto";
    }
  }


-- 
======================================================================================
Sven E. van 't Veer                                          
http://www.cachoeiro.net
Java Developer                                                      [EMAIL PROTECTED]
======================================================================================

Reply via email to