维基利亚加解密(二)
来源:互联网 发布:visual basic编程手机 编辑:程序博客网 时间:2024/05/29 18:50
/** * Created by y0n on 2017/4/21. */public class JavaCrackMe02 { public static char[][] arr = new char[][]{ {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}, {'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a'}, {'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b'}, {'d', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c'}, {'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd'}, {'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e'}, {'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f'}, {'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g'}, {'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}, {'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'}, {'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}, {'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'}, {'m', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'}, {'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'}, {'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'}, {'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'}, {'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'}, {'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'}, {'s', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r'}, {'t', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's'}, {'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't'}, {'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u'}, {'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v'}, {'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w'}, {'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x'}, {'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y'} }; public static char[] szBuf = new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; public static int getIndex(char ch) { for(int i = 0; i < szBuf.length; ++i) { if(ch == szBuf[i]) { return i; } } return -1; } public static String encode(String plaintext) { //String key = "abcdefghijklmnopqrstuvwxyz"; String key = "bcqedf"; StringBuffer stringbuffer = new StringBuffer(); for(int i = 0; i < plaintext.length(); ++i) { char ch = plaintext.charAt(i); int m = getIndex(ch); int n = getIndex(key.charAt(i % key.length())); System.out.println("坐标: x: " + m + " y: " + n + "字符 " + arr[m][n]); stringbuffer.append(arr[m][n]); } System.out.println(stringbuffer); return new String(stringbuffer); } public static int getIndex2(char ch, int n) { for(int i = 0; i < arr.length; ++i) { for (int j = 0; j < arr.length; j++) if(ch == arr[i][j] && n == j) { return i; } } return -1; } public static String DeCode(String cipherText) { //String key = "abcdefghijklmnopqrstuvwxyz"; String key = "bcqedf"; StringBuffer stringbuffer = new StringBuffer(); for(int i = 0; i < cipherText.length(); ++i) { char ch = cipherText.charAt(i); //int m = getIndex(ch); int n = getIndex(key.charAt(i % key.length())); int m = getIndex2(ch, n); System.out.println("坐标: x: " + m + " y: " + n + "字符 " + arr[m][n]); stringbuffer.append(szBuf[m]); } System.out.println(stringbuffer); return new String(stringbuffer); } public static void main(String []args) { encode("weijiniya"); DeCode("xgynlsjaq"); }}
阅读全文
0 0
- 维基利亚加解密(二)
- OpenVPN解密(二)
- jQuery :技术解密(二)
- JPEG算法解密(二)
- RecyclerView解密篇(二)
- JPEG算法解密(二)
- 网站优化技术全解密(二)
- java加密与解密(二)
- 庖丁解牛-----winpcap源码彻底解密(二)
- JAVA 3DES 加密解密(二)
- java DES 加密解密 (二)
- 加解密杂烩程序开发(二)
- 《加密与解密》笔记(二)
- 《加密与解密》笔记三(二)
- 《加密与解密》笔记四(二)
- 《加密与解密》笔记五(二)
- java中加密解密方式(二)
- jQuery技术解密二
- 忘记bug,去跑步吧
- Linux下的文件描述符
- leetcode(461) Hamming Distance 简单题
- Java基础面试题
- POJ 3422 Kaka's Matrix Travels 费用流
- 维基利亚加解密(二)
- LAMP+Wordpress+阿里云搭建个人博客
- Ubuntu16.04使用pip3安装第三方库
- FPGA内部结构
- TCP 传输链接的释放
- 项目实战:微交互之按钮选择器
- Ext Js入门第1篇-Ext环境搭建
- lg1071 潜伏者
- C++控制台读取和输出函数