Skip to main content

Posts

Showing posts from February, 2015

Encode from JavaScript and Decode at Java.

if you have a senerio like you want to send encoded parameter values from your web page  and decode them  at server side then this blog may be help you. JavaScript: Before submit the form I am encoding all the value entered by user so that it can not be read by humanly, for encoding the values I have written a method named  encodeBase64 <script> function encodeBase64(input){         var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";         input = escape(input);         var output = "";         var chr1, chr2, chr3 = "";         var enc1, enc2, enc3, enc4 = "";         var i = 0;              do {             chr1 = input.charCodeAt(i++);             chr2 = input.charCodeAt(i++);             chr3 = input.charCodeAt(i++);                      enc1 = chr1 >> 2;             enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);             enc3 = ((chr2 & 15) << 2