IoT CAS Frameworks/IOT_Server/Server_Admin_Framework/source/ConsumerAPI/src/java/license/EncryptDecrypt.java
public String decrypt(String encryptedString) {
        String decryptedText = null;
        try {
            cipher.init(Cipher.DECRYPT_MODE, secretKey, ivspec);
            System.out.println("decrypt(): After cipher init()..key= " + secretKey.toString() + "len=" + secretKey.toString().length());
            byte[] encryptedText = Base64.decodeBase64(encryptedString);
            System.out.println("decrypt(): encryptedText: " + encryptedText.toString());
            byte[] plainText = cipher.doFinal(encryptedText);
            System.out.println("decrypt(): plainText: " + plainText.toString());
            decryptedText = bytes2String(plainText);
        } catch (IllegalStateException e1) {
            System.out.println("decrypt(): IllegalState Exception: " + e1.getMessage());
            return null;
        } catch (InvalidKeyException e1) {
            System.out.println("decrypt(): Invalidkey Exception: " + e1.getMessage());
            return null;
        } catch (IllegalBlockSizeException e1) {
            System.out.println("decrypt(): IllegalBlockSize Exception: " + e1.getMessage());
            return null;
        } catch (BadPaddingException e1) {
            System.out.println("decrypt(): Padding Exception: " + e1.getMessage());
            return null;
        } catch (NullPointerException e1) {
            System.out.println("decrypt(): Padding Exception: " + e1.getMessage());
            return null;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return decryptedText;
    }
/**
     * Method To Decrypt the license key string
     */
Method To Decrypt the license key string
Method To Decrypt the license key string
public String decrypt(String encryptedString) {
        String decryptedText = null;
        try {
            cipher.init(Cipher.DECRYPT_MODE, secretKey, ivspec);
            System.out.println("decrypt(): After cipher init()..key= " + secretKey.toString() + "len=" + secretKey.toString().length());
            byte[] encryptedText = Base64.decodeBase64(encryptedString);
            System.out.println("decrypt(): encryptedText: " + encryptedText.toString());
            byte[] plainText = cipher.doFinal(encryptedText);
            System.out.println("decrypt(): plainText: " + plainText.toString());
            decryptedText = bytes2String(plainText);
        } catch (IllegalStateException e1) {
            System.out.println("decrypt(): IllegalState Exception: " + e1.getMessage());
            return null;
        } catch (InvalidKeyException e1) {
            System.out.println("decrypt(): Invalidkey Exception: " + e1.getMessage());
            return null;
        } catch (IllegalBlockSizeException e1) {
            System.out.println("decrypt(): IllegalBlockSize Exception: " + e1.getMessage());
            return null;
        } catch (BadPaddingException e1) {
            System.out.println("decrypt(): Padding Exception: " + e1.getMessage());
            return null;
        } catch (NullPointerException e1) {
            System.out.println("decrypt(): Padding Exception: " + e1.getMessage());
            return null;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return decryptedText;
    }
public String decrypt ( String encryptedString ) { String decryptedText = null ; try { cipher . init ( Cipher . DECRYPT_MODE , secretKey , ivspec ) ; System . out . println ( "decrypt(): After cipher init()..key= " + secretKey . toString ( ) + "len=" + secretKey . toString ( ) . length ( ) ) ; byte [ ] encryptedText = Base64 . decodeBase64 ( encryptedString ) ; System . out . println ( "decrypt(): encryptedText: " + encryptedText . toString ( ) ) ; byte [ ] plainText = cipher . doFinal ( encryptedText ) ; System . out . println ( "decrypt(): plainText: " + plainText . toString ( ) ) ; decryptedText = bytes2String ( plainText ) ; } catch ( IllegalStateException e1 ) { System . out . println ( "decrypt(): IllegalState Exception: " + e1 . getMessage ( ) ) ; return null ; } catch ( InvalidKeyException e1 ) { System . out . println ( "decrypt(): Invalidkey Exception: " + e1 . getMessage ( ) ) ; return null ; } catch ( IllegalBlockSizeException e1 ) { System . out . println ( "decrypt(): IllegalBlockSize Exception: " + e1 . getMessage ( ) ) ; return null ; } catch ( BadPaddingException e1 ) { System . out . println ( "decrypt(): Padding Exception: " + e1 . getMessage ( ) ) ; return null ; } catch ( NullPointerException e1 ) { System . out . println ( "decrypt(): Padding Exception: " + e1 . getMessage ( ) ) ; return null ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return decryptedText ; }
Method To Decrypt the license key string
Method To Decrypt the license key string