public String encodeEncryptionMethod(EncryptionMethod encryptionMethod) { StringBuffer s = new StringBuffer(""); switch (encryptionMethod.getEncryptionMethod()) { case EncryptionMethod.BASE64: s.append("base64:").append(encryptionMethod.getEncryptionKey()); break; case EncryptionMethod.CLEAR: s.append("clear:").append(encryptionMethod.getEncryptionKey()); break; case EncryptionMethod.URI: s.append("uri:").append(encryptionMethod.getEncryptionKey()); break; } return s.toString(); }
public static int encode(byte[] destination,int offset,EncryptionMethod encryptionMethod) { int usedLength=0; byte[] key=encryptionMethod.getEncryptionKey().getBytes(); switch (encryptionMethod.getEncryptionMethod()) { case EncryptionMethod.BASE64: System.arraycopy(BASE64_VALUE, 0, destination, offset, BASE64_VALUE.length); usedLength=BASE64_VALUE.length; System.arraycopy(key, 0, destination, offset+usedLength, key.length); usedLength+=key.length; break; case EncryptionMethod.CLEAR: System.arraycopy(CLEAR_VALUE, 0, destination, offset, CLEAR_VALUE.length); usedLength=CLEAR_VALUE.length; System.arraycopy(key, 0, destination, offset+usedLength, key.length); usedLength+=key.length; break; case EncryptionMethod.URI: System.arraycopy(URI_VALUE, 0, destination, offset, URI_VALUE.length); usedLength=URI_VALUE.length; System.arraycopy(key, 0, destination, offset+usedLength, key.length); usedLength+=key.length; break; } return usedLength; } }
public static int encode(byte[] destination,int offset,EncryptionMethod encryptionMethod) { int usedLength=0; byte[] key=encryptionMethod.getEncryptionKey().getBytes(); switch (encryptionMethod.getEncryptionMethod()) { case EncryptionMethod.BASE64: System.arraycopy(BASE64_VALUE, 0, destination, offset, BASE64_VALUE.length); usedLength=BASE64_VALUE.length; System.arraycopy(key, 0, destination, offset+usedLength, key.length); usedLength+=key.length; break; case EncryptionMethod.CLEAR: System.arraycopy(CLEAR_VALUE, 0, destination, offset, CLEAR_VALUE.length); usedLength=CLEAR_VALUE.length; System.arraycopy(key, 0, destination, offset+usedLength, key.length); usedLength+=key.length; break; case EncryptionMethod.URI: System.arraycopy(URI_VALUE, 0, destination, offset, URI_VALUE.length); usedLength=URI_VALUE.length; System.arraycopy(key, 0, destination, offset+usedLength, key.length); usedLength+=key.length; break; } return usedLength; } }