CryptUtils: new decrypts(..)
authorNiki Roo <niki@nikiroo.be>
Tue, 23 Apr 2019 06:53:37 +0000 (08:53 +0200)
committerNiki Roo <niki@nikiroo.be>
Tue, 23 Apr 2019 06:53:37 +0000 (08:53 +0200)
src/be/nikiroo/utils/CryptUtils.java

index b82a169ac21fffd4eb6d95f6df86c46a43566bfd..fdf05565b508c48f2c8d0722d2ce1b6a5a6cf38e 100644 (file)
@@ -267,6 +267,28 @@ public class CryptUtils {
                }
        }
 
+       /**
+        * Decode the data which is assumed to be encrypted with the same utilities
+        * and to be a {@link String}.
+        * 
+        * @param data
+        *            the encrypted data to decode
+        * 
+        * @return the original, decoded data,as a {@link String}
+        * 
+        * @throws SSLException
+        *             in case of I/O error
+        */
+       public String decrypts(byte[] data) throws SSLException {
+               try {
+                       return new String(decrypt(data), "UTF-8");
+               } catch (UnsupportedEncodingException e) {
+                       // UTF-8 is required in all confirm JVMs
+                       e.printStackTrace();
+                       return null;
+               }
+       }
+
        /**
         * Decode the data which is assumed to be encrypted with the same utilities
         * and is a Base64 encoded value.