JAVA电子密保生成
来源:互联网 发布:足球魔方大数据 编辑:程序博客网 时间:2024/05/17 08:37
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.util.Random;
import javax.imageio.*;
import java.awt.font.*;
import java.awt.geom.*;
/**
* JAVASecret security card generates
* @author Administrator
* Carefree (mail: xf_taoran@163.com)
* welcomes exchange of common learning
*
*/
public class CreatePasswordProtection {
public static void main(String[] args) throws Exception {
int width = 400;
int height = 300;
String title = "E-secret security card";
String index = "Serial Number : ";
String[] xindex = {"1","2","3","4","5","6"};
String[] yindex = {"A","B","C","D","E","F"};
/////////////////////////////////////////////////////////////////
Random random = new Random();
File file = new File("c:/image.jpg");
Font font = new Font("Serif", Font.BOLD, 14);
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = (Graphics2D)bi.getGraphics();
g2.setBackground(Color.WHITE);
g2.clearRect(0, 0, width, height);
g2.setPaint(Color.RED);
/////////////////////////////////////////////////////////////////
FontRenderContext context0 = g2.getFontRenderContext();
Rectangle2D bounds0 = font.getStringBounds(index, context0);
double x0 = 2;
double y0 = 2;
double ascent0 = -bounds0.getY();
double baseY0 = y0 + ascent0;
g2.drawString(title, (int)x0, (int)baseY0);
/////////////////////////////////////////////////////////////////
FontRenderContext context = g2.getFontRenderContext();
Rectangle2D bounds = font.getStringBounds(index, context);
double x = (width - 350);
double y = (height - 250);
double ascent = -bounds.getY();
double baseY = y + ascent;
index = index+(random.nextInt(8999)+1000)+" "+(random.nextInt(8999)+1000)+" "+(random.nextInt(8999)+1000)+" "+(random.nextInt(8999)+1000);
g2.drawString(index, (int)x, (int)baseY);
/////////////////////////////////////////////////////////////////
for (int i = 0; i < xindex.length; i++) {
double xx = (width - 350) + 40*(i+1);
double yx = (height - 250) + 30;
g2.drawString(xindex[i], (int)xx, (int)yx);
}
/////////////////////////////////////////////////////////////////
for (int i = 0; i < yindex.length; i++) {
double xy = (width - 350) - 10;
double yy = (height - 250) + 30 + 30*(i+1);
g2.drawString(yindex[i], (int)xy, (int)yy);
}
/////////////////////////////////////////////////////////////////
for (int j = 0; j < 7; j++) {
g2.drawLine(69, 85+30*j, 309, 85+30*j);
g2.drawLine(69+40*j, 85, 69+40*j, 265);
}
/////////////////////////////////////////////////////////////////
for (int j = 0; j < 6; j++) {
for (int i = 0; i < 6; i++) {
int sj = random.nextInt(999);
double xx = (width - 350) - 10 + 40*(i+1);
double yx = (height - 250) + 50 + 30*j;
g2.drawString(String.valueOf(sj), (int)xx, (int)yx);
}
}
ImageIO.write(bi, "jpg", file);
}
}
- JAVA电子密保生成
- 电子凭证 : Java 生成 Pdf
- Java何以保网络安全
- java实现pdf的生成下载打印,java生成pdf电子账单,java生成pdf合同模板
- 保 密 协 议
- 破解QQ密保
- 安全问题、密保问题......
- 用 DirectSound 生成电子鼓!
- C#生成电子印章源码
- JAVA电子资料大全
- JAVA电子资料大全
- Java电子商贸结构
- java 制作电子时钟
- JAVA电子时钟
- java电子签章
- 电子保卡与销售数据分析平台(ESA)一览
- netBeans 点击重置按钮 通过密保问题重置密码Java代码
- java数据保存在内存的什么地方?
- 【性能优化】续一
- SQL SERVER 中递归 层次显示数据信息
- ajax基本知识
- 。net验证的正则表达式
- 【Andriod 学习笔记1】--环境安装与配置
- JAVA电子密保生成
- Can money buy happiness?
- 参照的汇编没有安装在系统上
- 设置MyEclipse的字符集
- 为什么不压缩 HTML
- 江湖何人不流氓?
- Eclipse 字体配色
- tomcat6.0+struts2.2.1+spring2.5.6+ibatis2.3.4+mysql5.1最简开发环境配置及样例开发
- 如何通过CDC输出多行文本