@@ -39,7 +39,7 @@ public Crypto(String cipherKey, String customInitializationVector) {
3939 this .cipherKey = cipherKey ;
4040 }
4141
42- public void InitCiphers () throws PubnubException {
42+ public void InitCiphers () throws PubNubException {
4343 if (INIT )
4444 return ;
4545 try {
@@ -50,26 +50,26 @@ public void InitCiphers() throws PubnubException {
5050 ivBytes = initializationVector .getBytes ("UTF-8" );
5151 INIT = true ;
5252 } catch (UnsupportedEncodingException e ) {
53- throw PubnubException .builder ().pubnubError (newCryptoError (11 , e .toString ())).errormsg (e .getMessage ()).build ();
53+ throw PubNubException .builder ().pubnubError (newCryptoError (11 , e .toString ())).errormsg (e .getMessage ()).build ();
5454 }
5555 }
5656
57- public static byte [] hexEncode (byte [] input ) throws PubnubException {
57+ public static byte [] hexEncode (byte [] input ) throws PubNubException {
5858 StringBuffer result = new StringBuffer ();
5959 for (byte byt : input )
6060 result .append (Integer .toString ((byt & 0xff ) + 0x100 , 16 ).substring (1 ));
6161 try {
6262 return result .toString ().getBytes ("UTF-8" );
6363 } catch (UnsupportedEncodingException e ) {
64- throw PubnubException .builder ().pubnubError (newCryptoError (12 , e .toString ())).errormsg (e .getMessage ()).build ();
64+ throw PubNubException .builder ().pubnubError (newCryptoError (12 , e .toString ())).errormsg (e .getMessage ()).build ();
6565 }
6666 }
6767
68- private static PubnubError newCryptoError (int code , String message ) {
69- return PubnubError .getErrorObject (PubnubError .PNERROBJ_CRYPTO_ERROR , code , message );
68+ private static PubNubError newCryptoError (int code , String message ) {
69+ return PubNubError .getErrorObject (PubNubError .PNERROBJ_CRYPTO_ERROR , code , message );
7070 }
7171
72- public String encrypt (String input ) throws PubnubException {
72+ public String encrypt (String input ) throws PubNubException {
7373 try {
7474 InitCiphers ();
7575 AlgorithmParameterSpec ivSpec = new IvParameterSpec (ivBytes );
@@ -79,19 +79,19 @@ public String encrypt(String input) throws PubnubException {
7979 cipher .init (Cipher .ENCRYPT_MODE , newKey , ivSpec );
8080 return new String (Base64 .encode (cipher .doFinal (input .getBytes ("UTF-8" )), 0 ));
8181 } catch (NoSuchAlgorithmException e ) {
82- throw PubnubException .builder ().errormsg (e .toString ()).build ();
82+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
8383 } catch (NoSuchPaddingException e ) {
84- throw PubnubException .builder ().errormsg (e .toString ()).build ();
84+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
8585 } catch (InvalidKeyException e ) {
86- throw PubnubException .builder ().errormsg (e .toString ()).build ();
86+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
8787 } catch (InvalidAlgorithmParameterException e ) {
88- throw PubnubException .builder ().errormsg (e .toString ()).build ();
88+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
8989 } catch (UnsupportedEncodingException e ) {
90- throw PubnubException .builder ().errormsg (e .toString ()).build ();
90+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
9191 } catch (IllegalBlockSizeException e ) {
92- throw PubnubException .builder ().errormsg (e .toString ()).build ();
92+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
9393 } catch (BadPaddingException e ) {
94- throw PubnubException .builder ().errormsg (e .toString ()).build ();
94+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
9595 }
9696
9797 }
@@ -101,9 +101,9 @@ public String encrypt(String input) throws PubnubException {
101101 *
102102 * @param cipher_text
103103 * @return String
104- * @throws PubnubException
104+ * @throws PubNubException
105105 */
106- public String decrypt (String cipher_text ) throws PubnubException {
106+ public String decrypt (String cipher_text ) throws PubNubException {
107107 try {
108108 InitCiphers ();
109109 AlgorithmParameterSpec ivSpec = new IvParameterSpec (ivBytes );
@@ -112,21 +112,21 @@ public String decrypt(String cipher_text) throws PubnubException {
112112 cipher .init (Cipher .DECRYPT_MODE , newKey , ivSpec );
113113 return new String (cipher .doFinal (Base64 .decode (cipher_text , 0 )), "UTF-8" );
114114 } catch (IllegalArgumentException e ) {
115- throw PubnubException .builder ().errormsg (e .toString ()).build ();
115+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
116116 } catch (UnsupportedEncodingException e ) {
117- throw PubnubException .builder ().errormsg (e .toString ()).build ();
117+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
118118 } catch (IllegalBlockSizeException e ) {
119- throw PubnubException .builder ().errormsg (e .toString ()).build ();
119+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
120120 } catch (BadPaddingException e ) {
121- throw PubnubException .builder ().errormsg (e .toString ()).build ();
121+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
122122 } catch (InvalidKeyException e ) {
123- throw PubnubException .builder ().errormsg (e .toString ()).build ();
123+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
124124 } catch (InvalidAlgorithmParameterException e ) {
125- throw PubnubException .builder ().errormsg (e .toString ()).build ();
125+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
126126 } catch (NoSuchAlgorithmException e ) {
127- throw PubnubException .builder ().errormsg (e .toString ()).build ();
127+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
128128 } catch (NoSuchPaddingException e ) {
129- throw PubnubException .builder ().errormsg (e .toString ()).build ();
129+ throw PubNubException .builder ().errormsg (e .toString ()).build ();
130130 }
131131 }
132132
@@ -144,18 +144,18 @@ public static byte[] hexStringToByteArray(String s) {
144144 *
145145 * @param input
146146 * @return byte[]
147- * @throws PubnubException
147+ * @throws PubNubException
148148 */
149- public static byte [] md5 (String input ) throws PubnubException {
149+ public static byte [] md5 (String input ) throws PubNubException {
150150 MessageDigest digest ;
151151 try {
152152 digest = MessageDigest .getInstance ("MD5" );
153153 byte [] hashedBytes = digest .digest (input .getBytes ("UTF-8" ));
154154 return hashedBytes ;
155155 } catch (NoSuchAlgorithmException e ) {
156- throw PubnubException .builder ().pubnubError (newCryptoError (118 , e .toString ())).errormsg (e .getMessage ()).build ();
156+ throw PubNubException .builder ().pubnubError (newCryptoError (118 , e .toString ())).errormsg (e .getMessage ()).build ();
157157 } catch (UnsupportedEncodingException e ) {
158- throw PubnubException .builder ().pubnubError (newCryptoError (119 , e .toString ())).errormsg (e .getMessage ()).build ();
158+ throw PubNubException .builder ().pubnubError (newCryptoError (119 , e .toString ())).errormsg (e .getMessage ()).build ();
159159 }
160160 }
161161
@@ -164,16 +164,16 @@ public static byte[] md5(String input) throws PubnubException {
164164 *
165165 * @param input
166166 * @return byte[]
167- * @throws PubnubException
167+ * @throws PubNubException
168168 */
169- public static byte [] sha256 (byte [] input ) throws PubnubException {
169+ public static byte [] sha256 (byte [] input ) throws PubNubException {
170170 MessageDigest digest ;
171171 try {
172172 digest = MessageDigest .getInstance ("SHA-256" );
173173 byte [] hashedBytes = digest .digest (input );
174174 return hashedBytes ;
175175 } catch (NoSuchAlgorithmException e ) {
176- throw PubnubException .builder ().pubnubError (newCryptoError (111 , e .toString ())).errormsg (e .getMessage ()).build ();
176+ throw PubNubException .builder ().pubnubError (newCryptoError (111 , e .toString ())).errormsg (e .getMessage ()).build ();
177177 }
178178 }
179179
0 commit comments