Skip to content
Snippets Groups Projects
Select Git revision
  • 521f1c8ba245fc3400bb16b6880a96125ddeef70
  • master default
2 results

BCryptExample.java

Blame
  • Forked from cosc360-2016 / project-base
    Source project has a limited visibility.
    BCryptExample.java 444 B
    package model;
    
    import org.mindrot.jbcrypt.BCrypt;
    
    /**
     * A little demo code to show how BCrypt is used to hash passwords
     */
    public class BCryptExample {
    
        // Eek, not threadsafe.
        static String last;
    
        public static String encrypt(String s) {
            last = BCrypt.hashpw(s, BCrypt.gensalt());
            return last;
        }
    
        public static boolean matchesLastEncrypted(String pw) {
            return BCrypt.checkpw(pw, last);
        }
    
    }