本文介绍了XOR密码,替换密码和置换密码java编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请有人可以帮我组合XOR密码,替换密码和置换密码java编码吗?我已经做了编码,但得到了一些错误..任何人都可以帮我解决错误



import java。 util。*;



class question1 {



private final static String ALPHABET =abcdefghijklmnopqrstuvwxyz;

public static void main(String args [])

{



Scanner in = new Scanner(System。在); //定义扫描仪输入

String messageString;



System.out.println(请输入明文:);

messageString = in.nextLine(); //读一行

String cipherText =;

int shft = 5;

for(int i = 0; i< messagestring .length(); i ++)>

{

int charPosition = ALPHABET.indexOf(messageString.charAt(i));

int keyVal =(shft + charPosition)%26;

char replaceVal = this.ALPHABET.charAt(keyVal);

cipherText + = replaceVal;



}

int xor;

char temp;

for(int i = 0; i< messageString.length(); i ++){

xor = messageString.charAt(i)^ shft;

temp =(char)xor;

cipherText = cipherText + temp;

}

for(int i = 0; i< messagestring.length(); i ++)>

{

cipherText = messageString.length()^ [shft [i] -1];

}

}

}

Please anyone can help me the combine of XOR cipher , Substitution cipher and permutation cipher java coding? i already do to the coding but got some error..can anyone help me solve the error

import java. util.*;

class question1{

private final static String ALPHABET = "abcdefghijklmnopqrstuvwxyz";
public static void main (String args[])
{

Scanner in = new Scanner(System.in); //define scanner for input
String messageString;

System.out.println("Please enter the plaintext:");
messageString=in.nextLine(); //read a line
String cipherText ="";
int shft = 5;
for(int i=0;i<messagestring.length();i++)>
{
int charPosition = ALPHABET.indexOf(messageString.charAt(i));
int keyVal = (shft+charPosition)%26;
char replaceVal = this.ALPHABET.charAt(keyVal);
cipherText += replaceVal;

}
int xor;
char temp;
for(int i = 0 ; i < messageString.length() ; i++){
xor = messageString.charAt(i) ^ shft;
temp = (char)xor;
cipherText = cipherText+ temp;
}
for(int i=0;i<messagestring.length();i++)>
{
cipherText = messageString.length()^[shft[i] -1];
}
}
}

推荐答案


这篇关于XOR密码,替换密码和置换密码java编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 19:18