1
0
mirror of https://github.com/whvcse/EasyCaptcha.git synced 2024-11-23 01:59:19 +08:00

发布到maven仓库

This commit is contained in:
whvcse@foxmail.com 2019-08-27 01:05:34 +08:00
parent 2fff485de6
commit 32bf2d0773
3 changed files with 120 additions and 63 deletions

View File

@ -1,6 +1,6 @@
# EasyCaptcha # EasyCaptcha
![JitPack](https://img.shields.io/jitpack/v/whvcse/EasyCaptcha.svg?style=flat-square) ![MavenCentral](https://img.shields.io/maven-central/v/com.github.whvcse/easy-captcha)
![Hex.pm](https://img.shields.io/hexpm/l/plug.svg?style=flat-square) ![Hex.pm](https://img.shields.io/hexpm/l/plug.svg?style=flat-square)
@ -53,52 +53,33 @@
## 3.导入项目 ## 3.导入项目
### 3.1.gradle方式的引入 ### 3.1.gradle方式的引入
需要先在project的build.gradle中添加
```text
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```
在项目的build.gradle中添加
```text ```text
dependencies { dependencies {
compile 'com.github.whvcse:EasyCaptcha:1.6.2' compile 'com.github.whvcse:easy-captcha:1.6.2'
} }
``` ```
### 3.2.maven方式引入 ### 3.2.maven方式引入
在你的pom.xml中添加如下代码
```xml ```xml
<project> <dependencies>
<repositories> <dependency>
<repository> <groupId>com.github.whvcse</groupId>
<id>jitpack.io</id> <artifactId>easy-captcha</artifactId>
<url>https://jitpack.io</url> <version>1.6.2</version>
</repository> </dependency>
</repositories> </dependencies>
<dependencies>
<dependency>
<groupId>com.github.whvcse</groupId>
<artifactId>EasyCaptcha</artifactId>
<version>1.6.2</version>
</dependency>
</dependencies>
</project>
``` ```
### 3.3.jar包下载 ### 3.3.jar包下载
[EasyCaptcha-1.6.2.jar](https://gitee.com/whvse/EasyCaptcha/releases) [easy-captcha-1.6.2.jar](https://gitee.com/whvse/EasyCaptcha/releases)
maven导入jar包在项目根目录创建`libs`文件夹然后pom.xml添加如下 maven导入jar包在项目根目录创建`libs`文件夹然后pom.xml添加如下
``` ```
<dependency> <dependency>
<groupId>com.github.whvcse</groupId> <groupId>com.github.whvcse</groupId>
<artifactId>EasyCaptcha</artifactId> <artifactId>easy-captcha</artifactId>
<version>1.6.1</version> <version>1.6.1</version>
<systemPath>${basedir}/libs/EasyCaptcha-1.6.2.jar</systemPath> <systemPath>${basedir}/libs/easy-captcha-1.6.2.jar</systemPath>
</dependency> </dependency>
``` ```

127
pom.xml
View File

@ -2,16 +2,52 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wf</groupId> <groupId>com.github.whvcse</groupId>
<artifactId>easy-captcha</artifactId> <artifactId>easy-captcha</artifactId>
<version>1.6.2-RELEASE</version> <version>1.6.2</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>EasyCaptcha</name> <name>EasyCaptcha</name>
<description>Java图形验证码支持gif验证码、中文验证码适用于Java Web、JavaSE项目。</description> <description>Java web graphics verification code, support gif verification code.</description>
<url>https://github.com/whvcse/EasyCaptcha</url> <url>https://github.com/whvcse/EasyCaptcha</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<name>whvcse</name>
<email>whvcse@foxmail.com</email>
</developer>
</developers>
<scm>
<connection>scm:git@github.com:whvcse/EasyCaptcha.git</connection>
<developerConnection>scm:git@github.com:whvcse/EasyCaptcha.git</developerConnection>
<url>https://github.com/whvcse/EasyCaptcha</url>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies> <dependencies>
<!-- j2ee环境 --> <!-- j2ee环境 -->
<dependency> <dependency>
@ -28,28 +64,65 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build> <profiles>
<plugins> <profile>
<plugin> <id>release</id>
<groupId>org.apache.maven.plugins</groupId> <build>
<artifactId>maven-compiler-plugin</artifactId> <plugins>
<configuration> <!-- Source -->
<source>6</source> <plugin>
<target>6</target> <groupId>org.apache.maven.plugins</groupId>
<encoding>UTF-8</encoding> <artifactId>maven-source-plugin</artifactId>
</configuration> <version>2.2.1</version>
</plugin> <executions>
</plugins> <execution>
</build> <phase>package</phase>
<goals>
<distributionManagement> <goal>jar-no-fork</goal>
<repository> </goals>
<id>rdc-releases</id> </execution>
<url>https://repo.rdc.aliyun.com/repository/70786-release-exL3mB/</url> </executions>
</repository> </plugin>
<snapshotRepository> <!-- Javadoc -->
<id>rdc-snapshots</id> <plugin>
<url>https://repo.rdc.aliyun.com/repository/70786-snapshot-Y0tgOa/</url> <groupId>org.apache.maven.plugins</groupId>
</snapshotRepository> <artifactId>maven-javadoc-plugin</artifactId>
</distributionManagement> <version>2.9.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GPG -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>oss</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>oss</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</profile>
</profiles>
</project> </project>

View File

@ -1,14 +1,12 @@
package com.wf.captcha.base; package com.wf.captcha.base;
import sun.misc.BASE64Encoder;
import java.awt.*; import java.awt.*;
import java.awt.geom.CubicCurve2D; import java.awt.geom.CubicCurve2D;
import java.awt.geom.QuadCurve2D; import java.awt.geom.QuadCurve2D;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Base64;
/** /**
* 验证码抽象类 * 验证码抽象类
@ -111,18 +109,23 @@ public abstract class Captcha extends Randoms {
*/ */
public abstract boolean out(OutputStream os); public abstract boolean out(OutputStream os);
/**
* 输出base64编码
*
* @return base64编码字符串
*/
public abstract String toBase64(); public abstract String toBase64();
/** /**
* 输出base64编码 * 输出base64编码
* *
* @param type 编码头 * @param type 编码头
* @return * @return base64编码字符串
*/ */
public String toBase64(String type) { public String toBase64(String type) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
out(outputStream); out(outputStream);
return type + new BASE64Encoder().encode(outputStream.toByteArray()); return type + Base64.getEncoder().encodeToString(outputStream.toByteArray());
} }
/** /**