Package org.jasypt.digest

Examples of org.jasypt.digest.StandardByteDigester


   */
  @Test
  public void testDigesters() throws Exception {
    /* BYTE Digester */
    // Create a byte digester
    StandardByteDigester byteDigester = new StandardByteDigester();
    // Configure it
    byteDigester.setAlgorithm("SHA-512");
    byteDigester.setSaltSizeBytes(128);
    // Load binary data from a image file
    byte[] data = IOUtils.toByteArray(this.getClass().getResourceAsStream("/jasypt.png"));
    // Generate a digest
    byte[] digest = byteDigester.digest(data);
    // Display it
    String str = String.valueOf(Hex.encodeHex(digest));
    System.out.printf("testDigesters : Byte digest '%s'\n", str);
    /* STRING Digester */
    // Create a String digester
View Full Code Here


     * {@link #setAlgorithm(String)}.
     *
     */
    public Digester() {
        super();
        this.digester = new StandardByteDigester();
        this.digester.setIterations(ITERATIONS);
        this.digester.setSaltSizeBytes(SALT_SIZE_BYTES);
    }
View Full Code Here

     * the algorithm to be used.
     * </p>
     */
    public Digester(String algorithm) {
        super();
        this.digester = new StandardByteDigester();
        this.digester.setIterations(ITERATIONS);
        this.digester.setSaltSizeBytes(SALT_SIZE_BYTES);
        this.digester.setAlgorithm(algorithm);
    }
View Full Code Here

     *
     * @since 1.3
     */
    public Digester(String algorithm, String providerName) {
        super();
        this.digester = new StandardByteDigester();
        this.digester.setIterations(ITERATIONS);
        this.digester.setSaltSizeBytes(SALT_SIZE_BYTES);
        this.digester.setAlgorithm(algorithm);
        this.digester.setProviderName(providerName);
    }
View Full Code Here

     *
     * @since 1.3
     */
    public Digester(String algorithm, Provider provider) {
        super();
        this.digester = new StandardByteDigester();
        this.digester.setIterations(ITERATIONS);
        this.digester.setSaltSizeBytes(SALT_SIZE_BYTES);
        this.digester.setAlgorithm(algorithm);
        this.digester.setProvider(provider);
    }
View Full Code Here

     * {@link #setAlgorithm(String)}.
     *
     */
    public Digester() {
        super();
        this.digester = new StandardByteDigester();
        this.digester.setIterations(ITERATIONS);
        this.digester.setSaltSizeBytes(SALT_SIZE_BYTES);
    }
View Full Code Here

     * the algorithm to be used.
     * </p>
     */
    public Digester(final String algorithm) {
        super();
        this.digester = new StandardByteDigester();
        this.digester.setIterations(ITERATIONS);
        this.digester.setSaltSizeBytes(SALT_SIZE_BYTES);
        this.digester.setAlgorithm(algorithm);
    }
View Full Code Here

     *
     * @since 1.3
     */
    public Digester(final String algorithm, final String providerName) {
        super();
        this.digester = new StandardByteDigester();
        this.digester.setIterations(ITERATIONS);
        this.digester.setSaltSizeBytes(SALT_SIZE_BYTES);
        this.digester.setAlgorithm(algorithm);
        this.digester.setProviderName(providerName);
    }
View Full Code Here

     *
     * @since 1.3
     */
    public Digester(final String algorithm, final Provider provider) {
        super();
        this.digester = new StandardByteDigester();
        this.digester.setIterations(ITERATIONS);
        this.digester.setSaltSizeBytes(SALT_SIZE_BYTES);
        this.digester.setAlgorithm(algorithm);
        this.digester.setProvider(provider);
    }
View Full Code Here

    }

    @Override
    protected CharArrayPasswordEncoder createCharEncoder() {
        return new CharArrayPasswordEncoder() {
            StandardByteDigester digester = new StandardByteDigester();
            {
                digester.setAlgorithm("SHA-256");
                digester.setIterations(100000);
                digester.setSaltSizeBytes(16);
                digester.initialize();
            }
           
            @Override
            public String encodePassword(char[] rawPass, Object salt) {
                return new String(Base64.encodeBase64(digester.digest(toBytes(rawPass))));
            }
            @Override
            public boolean isPasswordValid(String encPass, char[] rawPass, Object salt) {
                return digester.matches(toBytes(rawPass), Base64.decodeBase64(encPass.getBytes()));
            }
        };
    }
View Full Code Here

TOP

Related Classes of org.jasypt.digest.StandardByteDigester

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.