herrDeng網內搜尋

自訂搜尋

Ads

2012年9月21日 星期五

請破譯Caesar shift cipher

xgbzft



有用程式碼者請PO源碼
Hint:

static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}

63 則留言:

B10033178 莊元泰 提到...

明文:enigma

老師,程式碼這樣貼可以嗎?
如果不行或有錯誤,麻煩老師告知,謝謝

程式碼:
package 密碼1;
import java.util.*;
public class 密碼1_2
{
 static char T(char p,int key)
 {
System.out.print( (char) (((int)(p-'a')+26-key)%26+'a'));
  return 0;
 }
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("請輸入密文");
String a=sc.next();
char A[]=new char[a.length()];

for(int i=0 ;i<A.length;i++)
A[i]=a.charAt(i);

for(int K=1;K<26; K++)
{
System.out.print("當KEY="+K+"時");
 for(int i=0 ;i<A.length;i++)
 {
 char ch=A[i];
 T(ch,K);
 }
System.out.println("");

B10033157 吳俊廷 提到...

X=24,G=7,B=2,Z=26,F=6,T=20
各減-1 到第7次得出
ENIGMA


B10033078 劉衿志 提到...

如無意外的話,明文是"ENIGMA"
且鑰匙是第 7 把


此程式碼使用 javascript 撰寫(不是 JAVA )
程式碼:
http://paste.plurk.com/show/1316919/

可操作的網頁版:
http://momijicore.co.cc/test/Caesar.html

B10033142劉舒萍 提到...

package P1;
import java.util.*;
public class 密碼學
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("輸入密文:");
z=sc.next();
char x[] =new char [z.length()];
int i=0,a=1;
while(i<x.length)
{
x[i]=z.charAt(i);
i++;
}
while(a<=25)
{
System.out.println("");
int q=0;
System.out.print("key="+a+" ");
while(q<x.length)
{
System.out.print(decrypt(x[q], a));
q++;
}
a++;
}
}

}

答案: key=19 enigma 翻譯:謎
翻譯出處:http://www.bing.com/translator/?MKT=zh-TW

B10033139周政潔 提到...

static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("輸入密文");
String a = sc.next();
int s = a.length();
char[] b = a.toCharArray();
for(int j=1;j<=26;j++){
System.out.println("第"+j+"把鑰匙");
for(int i=0;i<s;i++){
System.out.print(decrypt(b[i],j));
}
System.out.println();
}
}

第19把鑰匙:enigma

B10033140李政修 提到...

package tt;
import java.util.*;
public class t1 {
static char decrypt(char p,int key){
return(char) (((int)(p-'a')+26-key)%26+'a');
}
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.println("請輸入密文");
String a=sc.next();
char p[]=new char[a.length()];
for(int i=0 ;i<p.length;i++)
p[i]=a.charAt(i);
for(int j=1;j<26; j++){
for(int i=0 ;i<p.length;i++){
char t=p[i];
System.out.print(decrypt(t,j));
}
System.out.println("");
}
}
}

明文:enigma

B1033153 劉康連 提到...

明文是Enigma
Caesar shift cipher 是以英文字母為數值增加,改變的元單字改寫方法
X=24,G=7,B=2,Z=26,F=6,T=20
以每次-1的方式暴力破解,會在K=7時得到
Enigma

B10033025林煒翔 提到...

xgbzft
yhcagu
zidbhv
ajeciw
bkfdjx
clgeky
dmhflz
enigma=ENIGMA密碼有意義

明文:enigma

B9933045 鄭家燕 提到...

在第19把金鑰得出明文:enigma

原始碼:
package enigma;
import java.util.*;
public class CaesarShiftCipher
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("輸入密文");
String ciphertext =input.next();
char text[]=new char[ciphertext.length()];
int no = 0,
textlenght = ciphertext.length();
while(no != textlenght)
{
text[no] = ciphertext.charAt(no);
no++;
}
//System.out.println(text); xgbzft
for (int i=1;i<=26;i++)
{
System.out.print("第"+i+"把金鑰:");
for (int j=0;j<text.length;j++)
{System.out.print(decrypt(text[j],i));}
System.out.println();
}
}
}

b10033101 林劭文 提到...

X=23 G=4 B=1 Z=25 F=5 T=19
M-K(MOD26)
K=19
23-19(MOD26)=4=E
4-19(MOD26)=13=N
1-19(MOD26)=8=I
25-19(MOD26)=2=C
5-19(MOD26)=12=M
T-19(MOD26)=0=A

b10033016許俊翔 提到...

X=23 G=4 B=1 Z=25 F=5 T=19
M(23 4 1 25 5 19)-K(MOD26)
K=1~19
求得:
23-19(MOD26)=4=E
4-19(MOD26)=13=N
1-19(MOD26)=8=I
25-19(MOD26)=2=C
5-19(MOD26)=12=M
T-19(MOD26)=0=A
Ans: enicma

B9933061 盧柏瑋 提到...

1:YHCAGU
2:ZIDBHV
3:AJECIW
4:BKFDJX
5:CLGEKY
6:DMHFLZ
7:ENIGMA
8:FOJHNB
9:GPKIOC
10:HQLJPD
11:IRMKQE
12:JSNLRF
13:KTOMSG
14:LUPNTH
15:MVQOUI
16:NWRPVJ
17:OXSQWK
18:PYTRXL
19:QZUSYM
20:RAVTZN
21:SBWUAO
22:TCXVBP
23:UDYWCQ
24:VEZXDR
25:WFAYES
由第7把
得出明文"ENIGMA"

B10033121 莊宛積 提到...

ENIGMA
X=24,G=7,B=2,Z=26,F=6,T=20
Xgbzft每次-1的方法暴力破解在第7次時得到明文ENIGMA

B10033133 蕭志霖 提到...

package P1;
import java.util.*;
public class 密碼學作業
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("密文輸入:");
z=sc.next();
char y[] =new char [z.length()];
int i=0,u=1;
for(int g=0 ;g<y.length;g++)
{
y[i]=z.charAt(g);
}
while(u<=25)
{
System.out.println("");
int q=0;
System.out.print("第"+u+"把key");
while(q<y.length)
{
System.out.print(decrypt(y[q], u));
q++;
}
u++;
}
}
}

第19把key:enigma

B10033145黃意中 提到...

package work1;
import java.util.*;
public class Use035
{

static char 密碼文(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{

Scanner sc=new Scanner(System.in);
System.out.print("輸入密文");
String a = sc.next();
int s = a.length();
char[] b = a.toCharArray();
for(int x=1;x<=26;x++)
{
System.out.println("第"+x+"把鑰匙");
for(int i=0;i<s;i++)
{
System.out.print(密碼文(b[i],x));
}
System.out.println();
}
}
}
第19把KEY:enigma

B10033069 陳昱安 提到...

明文 : ENIGMA

X=24,G=7,B=2,Z=26,F=6,T=20

KEY = 7

參考網址:http://web.forret.com/tools/rot13.asp?rot=7&cipher=XGBZFT&clear=xgbzft&dir=encrypt

B10033160 鄭楷弘 提到...

package P1;
import java.util.*;
public class B10033160
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("輸入密文:");
z=sc.next();
char x[] =new char [z.length()];
int i=0,a=1;
while(i<x.length)
{
x[i]=z.charAt(i);
i++;
}
while(a<=25)
{
System.out.println("");
int q=0;
System.out.print("key="+a+" ");
while(q<x.length)
{
System.out.print(decrypt(x[q], a));
q++;
}
a++;
}
}

}


key=19 enigma

B10033109陳瑩淑 提到...

程式碼:
function decodeCaesar(input){

output=new Array;
chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
output_.innerHTML="";

for(i=0;i<26;i++){
str=new String;
for(j=0;j<input.length;j++){
str+=chars[(chars.search(input.charAt(j))+i)%26];
}
output.push(str);
}
return output;
}

鑰匙是第 7 把

可操作的網頁版:
http://momijicore.co.cc/test/Caesar.html

B10033065徐翊菱 提到...

decodeCaesar(input){

output=new Array;
chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
output_.innerHTML="";

for(i=0;i<26;i++){
str=new String;
for(j=0;j<input.length;j++){
str+=chars[(chars.search(input.charAt(j))+i)%26];
}
output.push(str);
}
return output;
}

且鑰匙是第 7 把

可操作的網頁版:
http://momijicore.co.cc/test/Caesar.html

B9933085羅智謙 提到...

根據解密函數D(c)=c-k k的範圍從1到25
當k=19可解出明文 enigma

B9933069李孝恩 提到...

明文:ENIGMA

解密的網頁:https://sites.google.com/site/913notebook/nwlahyc-yjcq-rb-odw-pjvn-cx-yujh

b9933079劉建承 提到...

XGBZFT

ENIGMA

參考來源
https://sites.google.com/site/913notebook/nwlahyc-yjcq-rb-odw-pjvn-cx-yujh

B10033164 宋姵賢 提到...

package P1;
import java.util.*;
public class 密碼學作業
{
static char 密文(char p,int key){
return(char) (((int)(p-'a')+26-key)%26+'a');
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("輸入密文");
String a=sc.next();
char p[]=new char[a.length()];
for(int i=0 ;i<p.length;i++)
p[i]=a.charAt(i);
for(int b=1;b<26; b++)
{
System.out.print("第"+b+"組密碼");
for(int x=0 ;x<p.length;x++)
{
char t=p[x];
System.out.print(密文(t,b));
}
System.out.println("");
}
}
}

第19把鑰匙=enigma

B10033154 蔡孟庭 提到...

ENIGMA IST NICHT EINFACH ZU BRECHEN
package P1;
import java.util.*;
public class 密碼學作業
{
static char 密文(char p,int key){
return(char) (((int)(p-'a')+26-key)%26+'a');
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("輸入密文");
String a=sc.next();
char p[]=new char[a.length()];
for(int i=0 ;i<p.length;i++)
p[i]=a.charAt(i);
for(int b=1;b<26; b++)
{
System.out.print("第"+b+"組密碼");
for(int x=0 ;x<p.length;x++)
{
char t=p[x];
System.out.print(密文(t,b));
}
System.out.println("");
}
}
}


第19把鑰匙=enigma

B10033037徐瑜駿 提到...

X=24,G=7,B=2,Z=26,F=6,T=20
k=1~19
24-19(MOD26
7-19(mod26
2-19(mod26
26-19(mod26
6-19(mod26
20-19(mod26
A:ENIGMA

B9833015曾世宇 提到...

ENIGMA
X=24,G=7,B=2,Z=26,F=6,T=20
Xgbzft每次-1的方法暴力破解在第7次時得到ENIGMA

B10033155 鄭凱傑 提到...

decodeCaesar(input){

output=new Array;
chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
output_.innerHTML="";

for(i=0;i<26;i++){
str=new String;
for(j=0;j<input.length;j++){
str+=chars[(chars.search(input.charAt(j))+i)%26];
}
output.push(str);
}
return output;
}

且鑰匙是第 7 把

B10033135 葉忠仁 提到...

package P1;
import java.util.*;
public class 密碼學
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("輸入密文:");
z=sc.next();
char x[] =new char [z.length()];
int i=0,a=1;
while(i<x.length)
{
x[i]=z.charAt(i);
i++;
}
while(a<=25)
{
System.out.println("");
int q=0;
System.out.print("key="+a+" ");
while(q<x.length)
{
System.out.print(decrypt(x[q], a));
q++;
}
a++;
}
}

}

資料來源:翻譯出處:http://www.bing.com/translator/?MKT=zh-TW

B10033151吳上弘 提到...

static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("密文");
String x = sc.next();
int str = x.length();
char[] b = x.toCharArray();
for(int i=1;i<=26;i++){
System.out.println("第"+i+"把Key");
for(int j=0;j<str;j++){
System.out.print(decrypt(b[j],i));
}
System.out.println();
}
}

答:enigma

B10033173 劉珆 提到...

static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("輸入密文");
String a = sc.next();
int s = a.length();
char[] b = a.toCharArray();
for(int j=1;j<=26;j++){
System.out.println("第"+j+"把鑰匙");
for(int i=0;i<s;i++){
System.out.print(decrypt(b[i],j));
}
System.out.println();
}
}

第19把鑰匙:enigma

b10033112張峻源 提到...

package P1;
import java.util.*;
public class 密碼學
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("輸入密文:");
z=sc.next();
char x[] =new char [z.length()];
int i=0,a=1;
while(i<x.length)
{
x[i]=z.charAt(i);
i++;
}
while(a<=25)
{
System.out.println("");
int q=0;
System.out.print("key="+a+" ");
while(q<x.length)
{
System.out.print(decrypt(x[q], a));
q++;
}
a++;
}
}

}

答案: key=19 enigma 翻譯:謎
翻譯出處:http://www.bing.com/translator/?MKT=zh-TW

Unknown 提到...

明文是Enigma

B10033014鄧宇純 提到...

X=24,G=7,B=2,Z=26,F=6,T=20
Xgbzft每次-1的方法暴力破解在第7次時得到ENIGMA
0:XGBZFT
1:YHCAGU
2:ZIDBHV
3:AJECIW
4:BKFDJX
5:CLGEKY
6:DMHFLZ
7:ENIGMA
8:FOJHNB
9:GPKIOC
10:HQLJPD
11:IRMKQE
12:JSNLRF
13:KTOMSG
14:LUPNTH
15:MVQOUI
16:NWRPVJ
17:OXSQWK
18:PYTRXL
19:QZUSYM
20:RAVTZN
21:SBWUAO
22:TCXVBP
23:UDYWCQ
24:VEZXDR
25:WFAYES

B10033021簡良宇 提到...

ENIGMA
X=24,G=7,B=2,Z=26,F=6,T=20
0:XGBZFT
1:YHCAGU
2:ZIDBHV
3:AJECIW
4:BKFDJX
5:CLGEKY
6:DMHFLZ
7:ENIGMA(此碼有意義)

B10033156 黃春閔 提到...

package p1;
import java.util.*;
public class B10033156
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("輸入密文:");
z=sc.next();
char x[] =new char [z.length()];
int i=0,a=1;
while(i<x.length)
{
x[i]=z.charAt(i);
i++;
}
while(a<=25)
{
System.out.println("");
int q=0;
System.out.print("key="+a+" ");
while(q<x.length)
{
System.out.print(decrypt(x[q], a));
q++;
}
a++;
}
}

}


答案: enigma

b9933064 劉鈺淇 提到...

0.xgbzft
1.yhcagu
2.zidbhv
3.ajeciw
4.bkfdjx
5.clgeky
6.dmhflz
7.enigma
8.fojhnb
9.gpkoc
10.hqljpd
11.irmkqe
12.jsnlrf
13.ktomsg
14.lupnth
15.mvqoui
16.nwrpvj
17.oxsqwk
18.pytrxl
19.qzusym
20.ravtzn
21.sbwuao
22.tcxvbp
23.udywcq
24.vezxdr
25.wfayes

明文:enigma

B9933103吳秉儒 提到...

明文 : ENIGMA

X=24,G=7,B=2,Z=26,F=6,T=20

KEY = 7

B10033002卓孟杰 提到...

static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("輸入密文");
String a = sc.next();
int s = a.length();
char[] b = a.toCharArray();
for(int j=1;j<=26;j++){
System.out.println("第"+j+"把鑰匙");
for(int i=0;i<s;i++){
System.out.print(decrypt(b[i],j));
}
System.out.println();
}
}

第19把鑰匙:enigma

b10033009沈哲文 提到...

package P1;
import java.util.*;
public class hello
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("密文輸入:");
z=sc.next();
char y[] =new char [z.length()];
int i=0,u=1;
for(int g=0 ;g<y.length;g++)
{
y[i]=z.charAt(g);
}
while(u<=25)
{
System.out.println("");
int q=0;
System.out.print("第"+u+"把key");
while(q<y.length)
{
System.out.print(decrypt(y[q], u));
q++;
}
u++;
}
}
}

第19把key:enigma

b10033010賴韋任 提到...

package P1;
import java.util.*;
public class test
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("密文輸入:");
z=sc.next();
char y[] =new char [z.length()];
int i=0,u=1;
for(int g=0 ;g<y.length;g++)
{
y[i]=z.charAt(g);
}
while(u<=25)
{
System.out.println("");
int q=0;
System.out.print("第"+u+"把key");
while(q<y.length)
{
System.out.print(decrypt(y[q], u));
q++;
}
u++;
}
}
}

第19把key:enigma

b10033042林藝兆 提到...

package P1;
import java.util.*;
public class 密碼學作業
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("密文輸入:");
z=sc.next();
char y[] =new char [z.length()];
int i=0,u=1;
for(int g=0 ;g<y.length;g++)
{
y[i]=z.charAt(g);
}
while(u<=25)
{
System.out.println("");
int q=0;
System.out.print("第"+u+"把key");
while(q<y.length)
{
System.out.print(decrypt(y[q], u));
q++;
}
u++;
}
}
}

第19把key:enigma

b10033128謝佳妘 提到...

package P1;
import java.util.*;
public class b10033128
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("密文輸入:");
z=sc.next();
char y[] =new char [z.length()];
int i=0,u=1;
for(int g=0 ;g<y.length;g++)
{
y[i]=z.charAt(g);
}
while(u<=25)
{
System.out.println("");
int q=0;
System.out.print("第"+u+"把key");
while(q<y.length)
{
System.out.print(decrypt(y[q], u));
q++;
}
u++;
}
}
}

第19把key:enigma

B9933044 李宗育 提到...

X=24,G=7,B=2,Z=26,F=6,T=20
Key 7
明文:Enigma

B9833068林建弘 提到...

0:XGBZFT
1:YHCAGU
2:ZIDBHV
3:AJECIW
4:BKFDJX
5:CLGEKY
6:DMHFLZ
7:ENIGMA
8:FOJHNB
9:GPKIOC
10:HQLJPD
11:IRMKQE
12:JSNLRF
13:KTOMSG
14:LUPNTH
15:MVQOUI
16:NWRPVJ
17:OXSQWK
18:PYTRXL
19:QZUSYM
20:RAVTZN
21:SBWUAO
22:TCXVBP
23:UDYWCQ
24:VEZXDR
25:WFAYES

明文: ENIGMA

B9933078詹惠雯 提到...

k=0,xgbzft
k=1,yhcagu
k=2,zidbhv
k=3,ajeciw
k=4,bkfdjx
k=5,clgeky
k=6,dmhflz
k=7,enigma

明文:enigma

B9933110曾亭群 提到...

0.xgbzft
1.yhcagu
2.zidbhv
3.ajeciw
4.bkfdjx
5.clgeky
6.dmhflz
7.enigma
8.fojhnb
9.gpkoc
10.hqljpd
11.irmkqe
12.jsnlrf
13.ktomsg
14.lupnth
15.mvqoui
16.nwrpvj
17.oxsqwk
18.pytrxl
19.qzusym
20.ravtzn
21.sbwuao
22.tcxvbp
23.udywcq
24.vezxdr
25.wfayes

7:明文:enigma

匿名 提到...

package P1;
import java.util.*;
public class B9733002鍾志捷
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("密文輸入:");
z=sc.next();
char y[] =new char [z.length()];
int i=0,u=1;
for(int g=0 ;g<y.length;g++)
{
y[i]=z.charAt(g);
}
while(u<=25)
{
System.out.println("");
int q=0;
System.out.print("第"+u+"把key");
while(q<y.length)
{
System.out.print(decrypt(y[q], u));
q++;
}
u++;
}
}
}

第19把key:enigma

B10033042林藝兆 提到...

package tt;
import java.util.*;
public class t1 {
static char decrypt(char p,int key){
return(char) (((int)(p-'a')+26-key)%26+'a');
}
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.println("請輸入密文");
String a=sc.next();
char p[]=new char[a.length()];
for(int i=0 ;i<p.length;i++)
p[i]=a.charAt(i);
for(int j=1;j<26; j++){
for(int i=0 ;i<p.length;i++){
char t=p[i];
System.out.print(decrypt(t,j));
}
System.out.println("");
}
}
}

明文:enigma

B9733200劉德堂 提到...

package P1;
import java.util.*;
public class 密碼學作業
{
static char 密文(char p,int key){
return(char) (((int)(p-'a')+26-key)%26+'a');
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("輸入密文");
String a=sc.next();
char p[]=new char[a.length()];
for(int i=0 ;i<p.length;i++)
p[i]=a.charAt(i);
for(int b=1;b<26; b++)
{
System.out.print("第"+b+"組密碼");
for(int x=0 ;x<p.length;x++)
{
char t=p[x];
System.out.print(密文(t,b));
}
System.out.println("");
}
}
}

第19把鑰匙=enigma

b9833032 許勝雄 提到...

package P1;
import java.util.*;
public class 密碼學
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("輸入密文:");
z=sc.next();
char x[] =new char [z.length()];
int i=0,a=1;
while(i<x.length)
{
x[i]=z.charAt(i);
i++;
}
while(a<=25)
{
System.out.println("");
int q=0;
System.out.print("key="+a+" ");
while(q<x.length)
{
System.out.print(decrypt(x[q], a));
q++;
}
a++;
}
}

}

答案: key=19 enigma

B10033107簡嘉慧 提到...

k=0,xgbzft
k=1,yhcagu
k=2,zidbhv
k=3,ajeciw
k=4,bkfdjx
k=5,clgeky
k=6,dmhflz
k=7,enigma

明文:enigma

B10033143溫凱傑 提到...

package P1;
import java.util.*;
public class 密碼學
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("輸入密文:");
z=sc.next();
char x[] =new char [z.length()];
int i=0,a=1;
while(i<x.length)
{
x[i]=z.charAt(i);
i++;
}
while(a<=25)
{
System.out.println("");
int q=0;
System.out.print("key="+a+" ");
while(q<x.length)
{
System.out.print(decrypt(x[q], a));
q++;
}
a++;
}
}

}

資料來源:翻譯出處:http://www.bing.com/translator/?MKT=zh-TW

B9833102曾冠誌 提到...

1:YHCAGU
2:ZIDBHV
3:AJECIW
4:BKFDJX
5:CLGEKY
6:DMHFLZ
7:ENIGMA
8:FOJHNB
9:GPKIOC
10:HQLJPD
11:IRMKQE
12:JSNLRF
13:KTOMSG
14:LUPNTH
15:MVQOUI
16:NWRPVJ
17:OXSQWK
18:PYTRXL
19:QZUSYM
20:RAVTZN
21:SBWUAO
22:TCXVBP
23:UDYWCQ
24:VEZXDR
25:WFAYES
由第7把
得出明文"ENIGMA

b9833033林聖庭 提到...

package P1;
import java.util.*;
public class 密碼學
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("輸入密文:");
z=sc.next();
char x[] =new char [z.length()];
int i=0,a=1;
while(i<x.length)
{
x[i]=z.charAt(i);
i++;
}
while(a<=25)
{
System.out.println("");
int q=0;
System.out.print("key="+a+" ");
while(q<x.length)
{
System.out.print(decrypt(x[q], a));
q++;
}
a++;
}
}

}

答案: key=19 enigma

B10033175 戴鵬翊 提到...

0.xgbzft
1.yhcagu
2.zidbhv
3.ajeciw
4.bkfdjx
5.clgeky
6.dmhflz
7.enigma
8.fojhnb
9.gpkoc
10.hqljpd
11.irmkqe
12.jsnlrf
13.ktomsg
14.lupnth
15.mvqoui
16.nwrpvj
17.oxsqwk
18.pytrxl
19.qzusym
20.ravtzn
21.sbwuao
22.tcxvbp
23.udywcq
24.vezxdr
25.wfayes

7:明文:enigma

B9933108彭嘉竣 提到...

package P1;
import java.util.*;
public class 密碼學
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("輸入密文:");
z=sc.next();
char x[] =new char [z.length()];
int i=0,a=1;
while(i<x.length)
{
x[i]=z.charAt(i);
i++;
}
while(a<=25)
{
System.out.println("");
int q=0;
System.out.print("key="+a+" ");
while(q<x.length)
{
System.out.print(decrypt(x[q], a));
q++;
}
a++;
}
}

}

答案: key=19 enigma 翻譯:謎
翻譯出處:http://www.bing.com/translator/?MKT=zh-TW

B10033177林明輝 提到...

package tt;
import java.util.*;
public class t1 {
static char decrypt(char p,int key){
return(char) (((int)(p-'a')+26-key)%26+'a');
}
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.println("請輸入密文");
String a=sc.next();
char p[]=new char[a.length()];
for(int i=0 ;i<p.length;i++)
p[i]=a.charAt(i);
for(int j=1;j<26; j++){
for(int i=0 ;i<p.length;i++){
char t=p[i];
System.out.print(decrypt(t,j));
}
System.out.println("");
}
}
}

明文:enigma

B10033169 羅致堯 提到...

package P1;
import java.util.*;
public class 密碼學
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("輸入密文:");
z=sc.next();
char x[] =new char [z.length()];
int i=0,a=1;
while(i<x.length)
{
x[i]=z.charAt(i);
i++;
}
while(a<=25)
{
System.out.println("");
int q=0;
System.out.print("key="+a+" ");
while(q<x.length)
{
System.out.print(decrypt(x[q], a));
q++;
}
a++;
}
}

}

B10033169 羅致堯 提到...

package P1;
import java.util.*;
public class 密碼學
{
static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args)
{
String z;
Scanner sc= new Scanner(System.in);
System.out.println("輸入密文:");
z=sc.next();
char x[] =new char [z.length()];
int i=0,a=1;
while(i<x.length)
{
x[i]=z.charAt(i);
i++;
}
while(a<=25)
{
System.out.println("");
int q=0;
System.out.print("key="+a+" ");
while(q<x.length)
{
System.out.print(decrypt(x[q], a));
q++;
}
a++;
}
}

}

B10033042林藝兆 提到...

X=23 G=4 B=1 Z=25 F=5 T=19
M(23 4 1 25 5 19)-K(MOD26)
K=1~19
求得:
23-19(MOD26)=4=E
4-19(MOD26)=13=N
1-19(MOD26)=8=I
25-19(MOD26)=2=C
5-19(MOD26)=12=M
T-19(MOD26)=0=A
Ans: enicma

b9733191 提到...

程式碼:
function decodeCaesar(input){

output=new Array;
chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
output_.innerHTML="";

for(i=0;i<26;i++){
str=new String;
for(j=0;j<input.length;j++){
str+=chars[(chars.search(input.charAt(j))+i)%26];
}
output.push(str);
}
return output;
}

鑰匙是第 7 把

B9833057 蔡鉑塏 提到...

static char decrypt(char p, int Key)
{
return (char) (((int)(p-'a')+26-Key)%26+'a');
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("輸入密文");
String a = sc.next();
int s = a.length();
char[] b = a.toCharArray();
for(int j=1;j<=26;j++){
System.out.println("第"+j+"把鑰匙");
for(int i=0;i<s;i++){
System.out.print(decrypt(b[i],j));
}
System.out.println();
}
}

第19把鑰匙:enigma

b9733166 提到...

package tt;
import java.util.*;
public class t1 {
static char decrypt(char p,int key){
return(char) (((int)(p-'a')+26-key)%26+'a');
}
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.println("請輸入密文");
String a=sc.next();
char p[]=new char[a.length()];
for(int i=0 ;i<p.length;i++)
p[i]=a.charAt(i);
for(int j=1;j<26; j++){
for(int i=0 ;i<p.length;i++){
char t=p[i];
System.out.print(decrypt(t,j));
}
System.out.println("");
}
}
}

明文:enigma

Related Posts Plugin for WordPress, Blogger...

熱門文章