类 Security


  • public class Security
    extends Object
    Methods for doing secure authentication with MySQL-4.1 and newer.
    • 方法详细资料

      • xorString

        public static void xorString​(byte[] from,
                                     byte[] to,
                                     byte[] scramble,
                                     int length)
        Encrypt/Decrypt function used for password encryption in authentication Simple XOR is used here but it is OK as we encrypt random strings
        参数:
        from - IN Data for encryption
        to - OUT Encrypt data to the buffer (may be the same)
        scramble - IN Scramble used for encryption
        length - IN Length of data to encrypt
      • scramble411

        public static byte[] scramble411​(String password,
                                         byte[] seed,
                                         String passwordEncoding)
      • scramble411

        public static byte[] scramble411​(byte[] password,
                                         byte[] seed)
        Hashing for MySQL-4.1 authentication. Algorithm is as follows (c.f. sql/auth/password.c):
         SERVER: public_seed=create_random_string()
         send(public_seed)
        
         CLIENT: recv(public_seed)
         hash_stage1=sha1("password")
         hash_stage2=sha1(hash_stage1)
         reply=xor(hash_stage1, sha1(public_seed,hash_stage2))
         send(reply)
         
        参数:
        password - password
        seed - seed
        返回:
        bytes
      • scrambleCachingSha2

        public static byte[] scrambleCachingSha2​(byte[] password,
                                                 byte[] seed)
                                          throws DigestException
        Scrambling for caching_sha2_password plugin.
         Scramble = XOR(SHA2(password), SHA2(SHA2(SHA2(password)), Nonce))
         
        参数:
        password - password
        seed - seed
        返回:
        bytes
        抛出:
        DigestException - if an error occurs