package org.ros.chatto.captcha;

import java.awt.image.BufferedImage;
import java.util.Random;

public class SimpleCaptchaBehavior implements CaptchaBehaviour {
	@Override
	public BufferedImage generateCaptcha() {
		SimpleCaptcha simpleCaptcha = new SimpleCaptcha();
		return simpleCaptcha.getImagePng();
	}
	@Override
	public BufferedImage generateCaptcha(String captchaText) {
		SimpleCaptcha simpleCaptcha = new SimpleCaptcha(captchaText);
		return simpleCaptcha.getImagePng();
	}
	
	public String getRandomChars() {
        return getRandomChars(8);
    }
	
	public String getRandomChars(int quantity)
	{
		char[] randomString = new char[quantity];

        Random random = new Random();

        int capitalLetter;

        for (int i = 0; i < quantity; i++) {
            capitalLetter = 65 + random.nextInt(26);
            randomString[i] = (char) capitalLetter;
        }

        return new String(randomString);
	}

}
