public static String encriptPass(String password) { boolean newProtocol = true; // System.out.println("--------------userId : "+userId); // userId =1574403; // password = "******" ; StringBuffer builder = new StringBuffer(); if (newProtocol) {} if (newProtocol) { DataEncryption encrptor = null; try { encrptor = new DataEncryption(ENCRYPTION_KEY.getBytes("utf-8")); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } byte[] isoPassword = null; try { isoPassword = password.getBytes("utf-8"); byte[] encryptedPassword = encrptor.rockeTalkEncrypt(isoPassword); String base64Password = MyBase64.encode(encryptedPassword); builder.append(base64Password); } catch (Exception e) { e.printStackTrace(); } } else { builder.append(password); } if (newProtocol) {} // System.out.println("-----------------------encrepted // pass-------------------"+builder.toString()); return builder.toString().trim(); }
public static String encryptData(String data) { String base64EncryptedData = null; DataEncryption encrptor = null; try { encrptor = new DataEncryption(ENCRYPTION_KEY.getBytes("utf-8")); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } byte[] byteData = null; try { byteData = data.getBytes("utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } byte[] encryptedPassword = encrptor.rockeTalkEncrypt(byteData); // base64EncryptedData = Base64.encode(encryptedPassword, // 0);//MyBase64.encode(encryptedPassword); return new String(Base64.encode(encryptedPassword, 0)); }
public static String createRTAppKeyHeader(int userId, String password, boolean newProtocol) { // System.out.println("--------------userId : "+userId); // userId =1574403; // password = "******" ; if (password == null || userId <= 0) { return ""; } StringBuffer builder = new StringBuffer(); if (newProtocol) { builder.append("'"); } builder.append(userId); builder.append(":"); if (newProtocol) { DataEncryption encrptor = null; try { encrptor = new DataEncryption(ENCRYPTION_KEY.getBytes("utf-8")); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } byte[] isoPassword = null; try { isoPassword = password.getBytes("utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } byte[] encryptedPassword = encrptor.rockeTalkEncrypt(isoPassword); String base64Password = MyBase64.encode(encryptedPassword); builder.append(base64Password); } else { builder.append(password); } if (newProtocol) { builder.append("'"); } // System.out.println("-----------------------app key--------------------"+builder.toString()); return builder.toString().trim(); }