MySQLPacketAuthSwitchResponse.createWithCachingSha2Password constructor

MySQLPacketAuthSwitchResponse.createWithCachingSha2Password({
  1. required String password,
  2. required Uint8List challenge,
})

Implementation

factory MySQLPacketAuthSwitchResponse.createWithCachingSha2Password({
  required String password,
  required Uint8List challenge,
}) {
  if (password.isEmpty) {
    return MySQLPacketAuthSwitchResponse(authData: Uint8List(0));
  }
  final passwordBytes = utf8.encode(password);
  return MySQLPacketAuthSwitchResponse(
    authData: xor(
      sha256(passwordBytes),
      sha256(sha256(sha256(passwordBytes)) + challenge),
    ),
  );
}