@Override public String encodePassword(char[] rawPass, Object salt) { byte[] bytes = toBytes(rawPass); try { return new String(Base64.encode(byteEncrypter.encrypt(bytes))); } finally { scramble(bytes); } } };
byte[] encode(char[] passwd) { if (!config.isEncrypting()) { return toBytes(passwd); } // encrypt the password StandardPBEByteEncryptor encryptor = new StandardPBEByteEncryptor(); char[] key = key(); try { encryptor.setPasswordCharArray(key); return Base64.encodeBase64(encryptor.encrypt(toBytes(passwd))); } finally { scramble(key); } }
/** * Encrypt the given array and return the encrypted one * * @param array * @return enc-array */ public static byte[] getEncrypted(byte[] array) { return encryptor.encrypt(array); }
/** * Encrypts a byte array * * @param binary the byte array to be encrypted. * @see StandardPBEByteEncryptor#encrypt(byte[]) */ public byte[] encrypt(final byte[] binary) { return this.encryptor.encrypt(binary); }
/** * Encrypts a byte array * * @param binary the byte array to be encrypted. * @see StandardPBEByteEncryptor#encrypt(byte[]) */ public byte[] encrypt(final byte[] binary) { return this.encryptor.encrypt(binary); }
/** * Encrypts a byte array * * @param binary the byte array to be encrypted. * @see StandardPBEByteEncryptor#encrypt(byte[]) */ public byte[] encrypt(final byte[] binary) { return this.encryptor.encrypt(binary); }
/** * Encrypts a byte array * * @param binary the byte array to be encrypted. * @see StandardPBEByteEncryptor#encrypt(byte[]) */ public byte[] encrypt(final byte[] binary) { return this.encryptor.encrypt(binary); }
/** * Encrypts a byte array * * @param binary the byte array to be encrypted. * @see StandardPBEByteEncryptor#encrypt(byte[]) */ public byte[] encrypt(final byte[] binary) { return this.encryptor.encrypt(binary); }
/** * Encrypts a byte array * * @param binary the byte array to be encrypted. * @see StandardPBEByteEncryptor#encrypt(byte[]) */ public byte[] encrypt(final byte[] binary) { return this.encryptor.encrypt(binary); }
@Override protected byte[] crypt(byte[] input, int mode) throws GeneralSecurityException { if (mode==Cipher.ENCRYPT_MODE) { return enc.encrypt(input); } else { return enc.decrypt(input); } } };
public static byte[] encrypt(byte[] bytes, String key) { StandardPBEByteEncryptor encryptor = getEncryptor(key); return encryptor.encrypt(bytes); }
@Override protected byte[] crypt(byte[] input, int mode) throws GeneralSecurityException { if (mode == Cipher.ENCRYPT_MODE) { return enc.encrypt(input); } else { return enc.decrypt(input); } } };
System.out.println("start *****"); String text="The quick brown fox jumps over the lazy dog"; StandardPBEByteEncryptor encryptor=new StandardPBEByteEncryptor(); encryptor.setAlgorithm("PBEWithMD5AndDES"); encryptor.setPassword("HelloWorld"); byte[] encrypted=encryptor.encrypt(text.getBytes()); System.out.println("stop *****");
@Override public String encodePassword(char[] rawPass, Object salt) { byte[] bytes = toBytes(rawPass); try { return new String(Base64.encode(byteEncrypter .encrypt(bytes))); } finally { scramble(bytes); } } };
return this.pool[poolPosition].encrypt(message);
return this.pool[poolPosition].encrypt(message);
return this.pool[poolPosition].encrypt(message);
final byte[] encryptedMessage = this.byteEncryptor.encrypt(messageBytes);
StandardPBEByteEncryptor strongBinaryEncryptor = new StandardPBEByteEncryptor(); strongBinaryEncryptor.setAlgorithm("PBEWITHSHAAND192BITAES-CBC-BC"); strongBinaryEncryptor.setKeyObtentionIterations(1000); strongBinaryEncryptor.setProviderName(BouncyCastleProvider.PROVIDER_NAME); strongBinaryEncryptor.setPassword(password); byte[] encryptedBytes = strongBinaryEncryptor.encrypt(password);
/** * Encode the password * @param passwd * @return */ byte[] encode(char[] passwd) { if (!isEncrypting()) { return toBytes(passwd); } //encrypt the password StandardPBEByteEncryptor encryptor = new StandardPBEByteEncryptor(); char[] key = key(); try { encryptor.setPasswordCharArray(key); return Base64.encodeBase64(encryptor.encrypt(toBytes(passwd))); } finally { scramble(key); } }