title: how to encrypt and decrypt request and response using SHA512 algorithm
body: <p>I want to encrypt and decrypt the request and response of the web service(KSOAP or JSON) using <strong>SHA512</strong> algorithm with private and public keys in android.</p>
  
  <p>Does anyone have an idea on this. I don't have much experience on this. So please excuse me if i am wrong.</p>
  
  <p>i guess the below class is used for encrypting a string. I want to know how to decrypt the string. And also i want to know how to use the private/public keys in this.</p>
  
  <p>public class SHA2Demo {</p>
  
  <pre><code>/**
   * @param args
   */
  public static void main(String[] args) {
      // TODO Auto-generated method stub
      String message = "test";
  
      MessageDigest messageDigest = null;
      try {
          messageDigest = MessageDigest.getInstance("SHA-512");
      } catch (NoSuchAlgorithmException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
      }
  
      try {
          messageDigest.update(message.getBytes("UTF-16BE"));
      } catch (UnsupportedEncodingException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      byte[] digest = messageDigest.digest();
  
      StringBuffer digestInHex = new StringBuffer();
  
      for (int i = 0, l = digest.length; i &lt; l; i++) {
          // Preserve the bit representation when casting to integer.
          int intRep = digest[i] &amp; 0xFF;
          // Add leading zero if value is less than 0x10.
          if (intRep &lt; 0x10)  digestInHex.append('\u0030');
          // Convert value to hex.
          digestInHex.append(Integer.toHexString(intRep));
      }
  
      System.out.println(digestInHex.toString());
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Thanks in advance.</p>