「java电文密码」密码电文解密

博主:adminadmin 2023-01-18 05:00:15 312

今天给各位分享java电文密码的知识,其中也会对密码电文解密进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

求Java的MD5加密解密实现类。 要实现对用户的密码进行加密! 然后验证用户的密码!

我简单说下吧,加密就是存进数据库的时候变成MD5存进去,解密,就是对比的时候,将用户输入的密码转换成MD5和数据库里面的对比。

用java实现对EXCEL加打开密码的方法?

需要用到poi,加密用到HSSFWorkbook的writeProtectWorkbook方法。

具体实现如下:

package excel;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class Writer {

public static final String FILE = "./workbook.xls";

public static void main(String[] args) {

FileOutputStream fileOut = null;

try {

// 创 建一个工作薄

HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(FILE));

// 设置密 码 保 护 ·

wb.writeProtectWorkbook("password", "owner");

// 写入excel文件

fileOut = new FileOutputStream(FILE);

wb.write(fileOut);

fileOut.close();

} catch (IOException io) {

io.printStackTrace();

} finally {

if (fileOut != null) {

try {

fileOut.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

}

注:先创建一个workbook.xls把不然会报错。

Java 用户的密码该怎么加密存储

你可以选择用md5,将密码转成另外一个字符串加密,也可以自己写一个加密的算法。

java 输入一个数字显示随机密码(密码可以有数字和大小写字母)例如我输入4 随机就是4个密码!请大家帮助

import java.util.Random;

import java.util.Scanner;

public class Zhidao {

public static void main(String agrs[]) {

Scanner sc = new Scanner(System.in);

int num = sc.nextInt();

StringBuffer sb = new StringBuffer();

for(int i=0; inum; i++) {

int a = Math.abs((new Random()).nextInt(57));//产生0~57的随机数

if(a=9){//将0~9转为char的0~9

sb.append((char)(a+48));

}

else if(a33){//将10~33转为char的A~Z

sb.append((char)(a+55));

}

else{//将33~57转为char的a~z

sb.append((char)(a+63));

}

}

System.out.println(sb.toString());

}

}

java中如何进行密码校验

import java.util.*;

import java.io.*;

public class Test{

private String user = "aaa";

private String pass = "123";

private int num = 0;

private boolean islogin = false;

private double money = 0.0;

private String getInput(){

BufferedReader br = new BufferedReader(

new InputStreamReader(System.in));

String str = "";

try {

str = br.readLine();

if(!("".equals(str.trim()))) return str;

}

catch (Exception ex) {

ex.printStackTrace();

}

return null;

}

//查询账户余额

private void selectMoney(){

System.out.println ("余额:"+money);

}

//取款

private void getMoney(){

System.out.print("请输入要取的钱数:");

String getMoney = this.getInput();

if(getMoney!=null){

try {

money -= Double.parseDouble(getMoney);

}

catch (Exception ex) {

ex.printStackTrace();

}

}

}

//存款

private void setMoney(){

System.out.print("请输入要存的钱数:");

String setMoney = this.getInput();

if(setMoney!=null){

try {

money += Double.parseDouble(setMoney);

}

catch (Exception ex) {

ex.printStackTrace();

}

}

}

//密码修改

private void upPass(){

System.out.print("请输入新密码:");

String ps = this.getInput();

if(ps!=null) pass = ps;

}

//退出

private void exit(){

System.exit(0);

}

private void subMeun(){

System.out.println ("0.密码验证 1.查询账户余额 2.取款 3.存款 4.密码修改 5.退出");

System.out.print ("请输入选项:");

String option = this.getInput();

if(option!=null){

if("0".equals(option)){

this.loginMeun();

}

else if("1".equals(option)){

this.selectMoney();

}

else if("2".equals(option)){

this.getMoney();

}

else if("3".equals(option)){

this.setMoney();

}

else if("4".equals(option)){

this.upPass();

}

else if("5".equals(option)){

this.exit();

}

}

}

private void mainMenu(){

while(num3){

if(islogin){ //System.out.println ("登录成功");

num=0;

this.subMeun();

}

else this.loginMeun();

}

}

private void loginMeun(){

System.out.print ("user:");

String us = this.getInput();

if(us!=null){

System.out.print ("pass:");

String ps = this.getInput();

if(ps!=null){

islogin = this.isLogin(us,ps);

}

}

}

private boolean isLogin(String us,String ps){

if(this.isUser(us)){

if(this.isPass(ps))

return true;

else{

num++;

return false;

}

}

return false;

}

private boolean isUser(String user){

if(this.user.equals(user))

return true;

else

return false;

}

private boolean isPass(String pass){

if(this.pass.equals(pass))

return true;

else

return false;

}

public static void main(String[] args){

Test t = new Test();

t.mainMenu();

}

}

java中怎么讲输入的密码化成"*"

  Java中可以使用replaceAll这个方法来进行转换:

   需要转义字符,.在正则表达式里面代表任何字符,修改a.replaceAll("\\.", "*"),这样就可以将输入的密码转换成“*”。在网页开发如果要使用密码的形式,可以直接将text的属性设置为text:password,这样系统就自动将输入的字符转换成“*”。

java电文密码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于密码电文解密、java电文密码的信息别忘了在本站进行查找喔。