I am using a login method that checks passwords and usernames in a phpbb installation.

i need to make this work to decrypt the phpbb encryption.

i am getting this error:


Code:
        vBulletin.java:139: error: non-static method phpbb_hash(String) cannot be referenced from a static context
                        pass2 = PHPBB3Password.phpbb_hash(password);
                                              ^
    1 error



This is my code:


Code:
    returnCodes[1] = group;
    String pass2 = "";
    if (forum == Type.myBB) {
        pass2 = MD5.MD5(MD5.MD5(salt) + MD5.MD5(password));
    } else if (forum == Type.vBulletin) {
        pass2 = MD5.MD5(password);
        pass2 = MD5.MD5(pass2 + salt);
    } else if (forum == Type.SMF) {
        pass2 = MD5.SHA((name.toLowerCase()) + password);
    } else if (forum == Type.phpBB) {
        pass2 = PHPBB3Password.phpbb_hash(password);
    } else if (forum == Type.IPB) {
        pass2 = MD5.MD5(MD5.MD5(salt) + MD5.MD5(password));
    }
it is the PhpBB i am using:
Code:
    
    public String phpbb_hash(String password) {
          String random_state = unique_id();
          String random = "";
          int count = 6;
    
          if (random.length() < count) {
             random = "";
    
             for (int i = 0; i < count; i += 16) {
                random_state = md5(unique_id() + random_state);
                random += pack(md5(random_state));
             }
             random = random.substring(0, count);
          }
    
          String hash = _hash_crypt_private(password, _hash_gensalt_private(random, itoa64));
          if (hash.length() == 34)
             return hash;
    
          return md5(password);
       }
And the old md5 decrypter which worked but wasnt up to date:
Code:
       
        public static String MD5(String text)
            throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest md;
        md = MessageDigest.getInstance("MD5");
        byte[] md5hash = new byte[32];
        md.update(text.getBytes("iso-8859-1"), 0, text.length());
        md5hash = md.digest();
        return convertToHex(md5hash);
    }
UPDATE: followed what some kind commenters had to say

if phpbb_hash uses some class attributes, then you need an instance of PHPBB3Password to access it. So you would do something like :
Code:
pass2 = new PHPBB3Password().phpbb_hash(password);
if phpbb_hash does not use some class attribute, then this method should be declared static like this:
Code:
public static String phpbb_hash(String password) {
...
}
Code:
        PHPBB3Password.java:18: error: non-static method unique_id() cannot be referenced from a static context
          String random_state = unique_id();
                                ^
    PHPBB3Password.java:26: error: non-static method unique_id() cannot be referenced from a static context
                random_state = md5(unique_id() + random_state);
                                   ^
    PHPBB3Password.java:32: error: non-static variable itoa64 cannot be referenced from a static context
          String hash = _hash_crypt_private(password, _hash_gensalt_private(random, itoa64));
                                                                                    ^
    PHPBB3Password.java:32: error: non-static method _hash_gensalt_private(String,String) cannot be referenced from a static context
          String hash = _hash_crypt_private(password, _hash_gensalt_private(random, itoa64));
                                                      ^
    PHPBB3Password.java:32: error: non-static method _hash_crypt_private(String,String) cannot be referenced from a static context
          String hash = _hash_crypt_private(password, _hash_gensalt_private(random, itoa64));
                        ^
    5 errors