Module bus.extra

Class AbstractStrategy

java.lang.Object
org.miaixz.bus.extra.captcha.strategy.AbstractStrategy
All Implemented Interfaces:
Serializable, CodeStrategy
Direct Known Subclasses:
RandomStrategy

public abstract class AbstractStrategy extends Object implements CodeStrategy
Abstract CAPTCHA code generation strategy. Generates a random CAPTCHA string from a given base character set and length.
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Field Details

    • baseStr

      protected final String baseStr
      The base character set from which to randomly select characters for the CAPTCHA string.
    • length

      protected final int length
      The length of the CAPTCHA code.
  • Constructor Details

    • AbstractStrategy

      public AbstractStrategy(int count)
      Constructor, using letters and numbers as the base set.
      Parameters:
      count - The length of the CAPTCHA code to generate.
    • AbstractStrategy

      public AbstractStrategy(String baseStr, int length)
      Constructor.
      Parameters:
      baseStr - The base character set from which to randomly select characters.
      length - The length of the CAPTCHA code to generate.
  • Method Details

    • getLength

      public int getLength()
      Gets the length of the CAPTCHA code.
      Returns:
      The length of the CAPTCHA code.