List of usage examples for java.util Arrays equals
public static boolean equals(Object[] a, Object[] a2)
From source file:com.cyberninjas.xerobillableexpenses.util.Settings.java
public Settings() { try {/*from w w w.j a v a2 s . c om*/ String parentClass = new Exception().getStackTrace()[1].getClassName(); this.prefs = Preferences.userNodeForPackage(Class.forName(parentClass)); Random r = new SecureRandom(); //Set IV this.iv = prefs.getByteArray("DRUGS", null); //Pick Random PWD byte[] b = new byte[128]; r.nextBytes(b); MessageDigest sha = MessageDigest.getInstance("SHA-1"); sha.update(b); String sHash = new String(Base64.encodeBase64(sha.digest())); String password = prefs.get("LAYOUT", sHash); if (password.equals(sHash)) prefs.put("LAYOUT", sHash); //Keep 'em Guessing r.nextBytes(b); sha.update(b); prefs.put("PASSWORD", new String(Base64.encodeBase64(sha.digest()))); //Set Random Salt byte[] tSalt = new byte[8]; r.nextBytes(tSalt); byte[] salt = prefs.getByteArray("HIMALAYAN", tSalt); if (Arrays.equals(salt, tSalt)) prefs.putByteArray("HIMALAYAN", salt); /* Derive the key, given password and salt. */ SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 65536, 128); SecretKey tmp = factory.generateSecret(spec); this.secret = new SecretKeySpec(tmp.getEncoded(), "AES"); cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(RSAx509CertGen.class.getName()).log(Level.SEVERE, null, ex); } catch (InvalidKeySpecException ex) { Logger.getLogger(RSAx509CertGen.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(RSAx509CertGen.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.enonic.cms.core.user.field.UserField.java
public boolean equals(UserField compareField) { if (compareField == null) { return false; } else if (getType() != compareField.getType()) { return false; } else if (getValue() == null && compareField.getValue() == null) { return true; } else if (getValue() == null && compareField.getValue() != null) { return false; } else if (getValue() != null && compareField.getValue() == null) { return false; } else {//from w ww . j ava2 s.co m if (isOfType(UserFieldType.PHOTO)) { byte[] commandPhoto = (byte[]) getValue(); byte[] remotePhoto = (byte[]) compareField.getValue(); if (!(Arrays.equals(commandPhoto, remotePhoto))) { return false; } } else { if (bothAreBlankStrings(getValue(), compareField.getValue())) { return true; } if (!(getValue().equals(compareField.getValue()))) { return false; } } } return true; }
From source file:com.shuffle.p2p.Bytestring.java
@Override public boolean equals(Object o) { return o instanceof Bytestring && Arrays.equals(bytes, ((Bytestring) o).bytes); }
From source file:edu.vt.middleware.webflow.ClientFlowExecutionKey.java
@Override public boolean equals(final Object o) { if (o == this) { return true; }// w ww.ja va 2s . c o m if (o == null || !(o instanceof ClientFlowExecutionKey)) { return false; } final ClientFlowExecutionKey other = (ClientFlowExecutionKey) o; return this.id.equals(other.id) && Arrays.equals(this.data, other.data); }
From source file:com.brighttag.agathon.model.CassandraInstance.java
@Override public boolean equals(Object obj) { if (obj == null) { return false; } else if (obj == this) { return true; } else if (!getClass().isAssignableFrom(obj.getClass())) { return false; }/*from ww w . ja v a 2s .c o m*/ return Arrays.equals(significantAttributes(), getClass().cast(obj).significantAttributes()); }
From source file:com.brienwheeler.apps.main.MainBaseTest.java
@Test public void testSkipBaseArgs() { String[] args = new String[] { P, TestDataConstants.PROPS_FILE1 }; Main1 main = new Main1(args); main.dontUseBastOpts();/*from w ww . j av a 2s .c o m*/ System.clearProperty(TestDataConstants.PROPS_FILE1_PROP); Assert.assertNull(System.getProperty(TestDataConstants.PROPS_FILE1_PROP)); main.run(); Assert.assertNull(System.getProperty(TestDataConstants.PROPS_FILE1_PROP)); ArrayList<String> processedArgs = main.getProcessedArgs(); Assert.assertTrue(Arrays.equals(args, processedArgs.toArray(new String[processedArgs.size()]))); }
From source file:edu.tamu.tcat.crypto.spongycastle.PBKDF2Impl.java
@Override protected boolean checkHash(byte[] password, String saltStr, String outputStr, DigestType digest, int rounds) { if (!Base64.isBase64(saltStr) || !Base64.isBase64(outputStr)) return false; byte[] salt = Base64.decodeBase64(saltStr); byte[] output = Base64.decodeBase64(outputStr); int outputSize = DigestTypeMap.getDigest(digest).getDigestSize(); if (output.length != outputSize) return false; PBKDF2Impl pbkdf2 = new PBKDF2Impl(digest); byte[] candidate = pbkdf2.deriveKey(password, salt, rounds, outputSize); return Arrays.equals(candidate, output); }
From source file:edu.cmu.tetrad.util.MatrixUtils.java
/** * Tests two matrices for equality./*from w w w . j a v a2 s. c o m*/ * * @param ma The first 2D matrix to check. * @param mb The second 2D matrix to check. * @return True iff the first and second matrices are equal. */ public static boolean equals(double[][] ma, double[][] mb) { if (ma.length != mb.length) return false; for (int i = 0; i < ma.length; i++) { double[] _ma = ma[i]; double[] _mb = mb[i]; if (!Arrays.equals(_ma, _mb)) return false; } return true; }
From source file:com.github.tomakehurst.wiremock.http.Body.java
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Body body = (Body) o;//from www. j a v a 2s . com return Objects.equals(binary, body.binary) && Arrays.equals(content, body.content); }
From source file:com.bitsofproof.supernode.api.BIP39Test.java
@Test public void bip39EncodeDecodeTest() throws IOException, JSONException, ValidationException { JSONObject testData = readObject(TESTS); JSONArray english = testData.getJSONArray("english"); for (int i = 0; i < testData.length(); ++i) { JSONArray test = english.getJSONArray(i); byte[] m = BIP39.decode(test.getString(1), "BOP"); assertTrue(test.getString(1).equals(BIP39.encode(m, "BOP"))); }//from www.j a v a 2s .c om SecureRandom random = new SecureRandom(); for (int i = 0; i < 1000; ++i) { byte[] secret = new byte[32]; random.nextBytes(secret); String e = BIP39.encode(secret, "BOP"); assertTrue(Arrays.equals(BIP39.decode(e, "BOP"), secret)); } }