List of usage examples for org.apache.commons.lang ArrayUtils clone
public static boolean[] clone(boolean[] array)
Clones an array returning a typecast result and handling null
.
From source file:edu.utah.further.core.api.math.ArithmeticUtil.java
/** * Return a cumulative sum array of an array * * @param array// w w w . j a v a 2s .c o m * original array of size n * @return array of size n whose ith element is sum_{j=0..i-1} (a[j]) */ public static double[] cumulativeSum(final double[] array) { final double[] cumsum = ArrayUtils.clone(array); // Compute by recursion for (int i = 1; i < cumsum.length; i++) { // A clever implementation. Since cumsum[i] = array[i], this computes // cumsum[i] = array[i] + cumsum[i-1] cumsum[i] += cumsum[i - 1]; } return cumsum; }
From source file:mitm.common.security.crypto.PBEncryptionOutputStream.java
public PBEncryptionOutputStream(OutputStream delegate, int iterationCount, int saltLength, String algorithm, char[] password) throws CryptoException { Check.notNull(delegate, "delegate"); Check.notNull(algorithm, "algorithm"); Check.notNull(password, "password"); this.delegate = delegate; this.iterationCount = iterationCount; this.saltLength = saltLength; this.algorithm = algorithm; this.password = ArrayUtils.clone(password); init();//from w ww.j a va 2 s. com }
From source file:app.Des.java
private String cipher(int[] message, List<int[]> keys) { int[] messPermuted = this.tables.getIP_Message(message); int[] messL = ArrayUtils.subarray(messPermuted, 0, messPermuted.length / 2); int[] messR = ArrayUtils.subarray(messPermuted, messPermuted.length / 2, messPermuted.length); for (int[] key1 : keys) { int[] eMessR = this.tables.getE_Message(messR); int[] xorResult = new int[eMessR.length]; for (int i = 0; i < eMessR.length; i++) { xorResult[i] = binMath.xor(eMessR[i], key1[i]); }/* www . ja va 2s . c o m*/ String row = ""; String column = ""; int[] sTransformedMess = new int[32]; int sTransformedIndex = 0; int sTableIndex = 0; for (int i = 0; i < xorResult.length; i = i + 6, sTableIndex++) { row = String.valueOf(xorResult[i]) + String.valueOf(xorResult[i + 5]); column = String.valueOf(xorResult[i + 1]) + String.valueOf(xorResult[i + 2]) + String.valueOf(xorResult[i + 3]) + String.valueOf(xorResult[i + 4]); int sTableNumber = this.tables.getSTables().get(sTableIndex)[Integer.parseInt(row, 2)][Integer .parseInt(column, 2)]; String binary = this.binMath.intToString(sTableNumber); for (int bin = 0; bin < binary.length(); bin++) { sTransformedMess[sTransformedIndex + bin] = Integer.parseInt(binary.charAt(bin) + ""); } sTransformedIndex += binary.length(); } int[] pMessage = this.tables.getP_Message(sTransformedMess); int[] tempR = new int[messR.length]; for (int i = 0; i < messL.length; i++) { tempR[i] = binMath.xor(messL[i], pMessage[i]); } messL = ArrayUtils.clone(messR); messR = ArrayUtils.clone(tempR); } int[] lastPermuted = this.tables.getIPInverse_Message(ArrayUtils.addAll(messR, messL)); String hex = binMath.fromBinStringToHexString(getString(lastPermuted, 0)); return hex; }
From source file:alpha.portal.model.AdornmentTypeRange.java
/** * Gets the valid strings.//from w ww. j av a 2 s . co m * * @return the valid strings */ public String[] getValidStrings() { return (String[]) ArrayUtils.clone(this.validStrings); }
From source file:alpha.portal.model.AdornmentTypeRange.java
/** * Sets the valid strings./* ww w . j av a 2s. c om*/ * * @param validStrings * the new valid strings */ public void setValidStrings(final String[] validStrings) { this.validStrings = (String[]) ArrayUtils.clone(validStrings); }
From source file:morphy.timeseal.TimesealCoder.java
public TimesealParseResult decode(byte[] bytes) { byte[] key = timesealKey; byte[] tmp = ArrayUtils.clone(bytes); int n;// w w w. j ava 2 s .c o m byte offset; int l = tmp.length; if (l % 12 != 1) { // malformed? //System.out.println("malformed"); } offset = tmp[l - 1]; for (n = 0; n < l; n++) { // n+offset+0x80 differs slightly from original C version, it was previously n+offset-0x80 // but since offset is -128, -128 - 0x80 (128) = -256, so it was not working properly. tmp[n] = (byte) ((tmp[n] + 32) ^ key[(n + offset + 0x80) % key.length]); if ((tmp[n] & 0x80) == 0) { // malformed? //System.out.println("malformed"); } tmp[n] ^= 0x80; } for (n = 0; n + 11 < l; n += 12) { SC(tmp, n, n + 11); SC(tmp, n + 2, n + 9); SC(tmp, n + 4, n + 7); } for (n = 0; n < tmp.length; n++) { if ((tmp[n] >> 5) == 0) { // malformed? //System.out.println("malformed"); } } // \x18 = \u0024 // \x19 = \u0025 int timeStartIdx = indexOfByte(tmp, (byte) 24); int timeEndIdx = indexOfByte(tmp, (byte) 25); String timestamp = new String(Arrays.copyOfRange(tmp, timeStartIdx + 1, timeEndIdx)); String message = new String(Arrays.copyOfRange(tmp, 0, timeStartIdx)); TimesealParseResult result = new TimesealParseResult(Long.parseLong(timestamp), message); return result; }
From source file:com.rb.ofbiz.test.utils.logging.TestMetricsBean.java
public String[] getCommandsExcludedFromLogging() { return (String[]) ArrayUtils.clone(commandsExcludedFromLogging); }
From source file:com.rb.ofbiz.test.utils.logging.TestMetricsBean.java
public void setCommandsExcludedFromLogging(String[] commandsExcludedFromLogging) { this.commandsExcludedFromLogging = (String[]) ArrayUtils.clone(commandsExcludedFromLogging); }
From source file:app.Des.java
private List<int[]> doKey() { int[] keyPermuted = this.tables.getPc1_Key(this.key); int[] keyL = ArrayUtils.subarray(keyPermuted, 0, keyPermuted.length / 2); int[] keyR = ArrayUtils.subarray(keyPermuted, keyPermuted.length / 2, keyPermuted.length); List<int[]> subkeysL = new ArrayList<>(); List<int[]> subkeysR = new ArrayList<>(); int[] lastL = Arrays.copyOf(keyL, keyL.length); int[] lastR = Arrays.copyOf(keyR, keyR.length); for (int shift : this.tables.getShiftKeyTable()) { int[] newKeyL = this.binMath.doLeftShift(lastL, shift); int[] newKeyR = this.binMath.doLeftShift(lastR, shift); subkeysL.add(newKeyL);//from www .j a v a 2s . c o m subkeysR.add(newKeyR); lastL = newKeyL; lastR = newKeyR; } List<int[]> mergedAndPermuted = new ArrayList<>(); for (int i = 0; i < subkeysL.size(); i++) { int[] tempKey = new int[this.B_56]; tempKey = ArrayUtils.clone(subkeysL.get(i)); tempKey = ArrayUtils.addAll(tempKey, subkeysR.get(i)); mergedAndPermuted.add(this.tables.getPc2_Key(tempKey)); } return mergedAndPermuted; }
From source file:com.sinosoft.one.mvc.web.impl.thread.InvocationBean.java
public String[] getMethodParameterNames() { return (String[]) ArrayUtils.clone(getActionEngine().getParameterNames()); }