How Encrypt the GWT String from Client Side

How Encrypt the GWT String from Client Side
  • Download the jar file from link.
  • Add the following in the .gwt.xml file 
  •         <inherits name=’com.googlecode.gwt.crypto.Crypto’/>

     

  • Use the following code in the class
                  String getSHA1for(String text) 
               {
  SHA1Digest sd = new SHA1Digest();
  byte[] bs = text.getBytes();
  sd.update(bs, 0, bs.length);
  byte[] result = new byte[20];
  sd.doFinal(result, 0);
  return byteArrayToHexString(result);
}
String byteArrayToHexString(final byte[] b) 
               {
  final StringBuffer sb = new StringBuffer(b.length * 2);
  for (int i = 0, len = b.length; i < len; i++) {
    int v = b[i] & 0xff;
    if (v < 16) sb.append(‘0’);
    sb.append(Integer.toHexString(v));
  }
  return sb.toString().toUpperCase();
}
Advertisements

4 thoughts on “How Encrypt the GWT String from Client Side

  1. Pocket CROSS Bikes December 29, 2013 at 10:39 pm Reply

    Thiis post gives clear idea for the new users of blogging,
    that really how to do blogging and site-building.

  2. nfsw boost codes January 14, 2014 at 1:42 pm Reply

    Spot on with this write-up, I actually believe this amazing site needs a
    great deal more attention. I’ll probably be back again to read more, thanks for the advice!

  3. Launch Corporate March 10, 2014 at 4:06 pm Reply

    Howdy just wanted to give you a quick heads up.
    The words in your article seem to be running off the screen in Opera.
    I’m not sure if this is a format issue or something
    to do with web browser compatibility but
    I figured I’d post to let you know. The style and design look great though!
    Hope you get the problem fixed soon. Thanks

  4. best driving school in sittingbourne March 13, 2014 at 8:33 am Reply

    Hey There. I found your blog using msn. This is an extremely
    well written article. I will be sure to bookmark it and
    return to read more of your useful info. Thanks for the post.
    I’ll certainly comeback.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: