class很好反编译,所以需要对class文件先进行加密,然后使用自己的classloader进行解密并加载。

【步骤】

大概分两步:

1.对class文件进行加密

2.写解密class文件并加载的classloader

3.将这个classloader加入到tomcat中,也就是使tomcat可以调用到这个classloader

【加密】

1.思路

字节流读取class文件,进行简单的移位

2.实现

做了一个小程序,实现了对某文件夹下所有class文件字节流读取,并+2位的加密方式

3.说明

swing是使用myeclipse的插件做的,可能比较乱

【classloader】

  1. import java.io.ByteArrayOutputStream;
  2. import java.io.FileInputStream;
  3. import java.io.IOException;
  4.  
  5. import org.apache.catalina.loader.WebappClassLoader;
  6.  
  7. /**
  8. * 自己的ClassLoader
  9. * 用于解密加密过的class文件并加载
  10. * @author uikoo9
  11. */
  12. public class MyClassLoader extends WebappClassLoader{
  13.  
  14. /**
  15. * 默认构造器
  16. */
  17. public MyClassLoader() {
  18. super();
  19. }
  20.  
  21. /**
  22. * 默认构造器
  23. * @param parent
  24. */
  25. public MyClassLoader(ClassLoader parent) {
  26. super(parent);
  27. }
  28.  
  29. /* (non-Javadoc)
  30. * @see org.apache.catalina.loader.WebappClassLoader#findClass(java.lang.String)
  31. */
  32. public Class<?> findClass(String name) throws ClassNotFoundException {
  33. byte[] classBytes = null;
  34.  
  35. try {
  36. classBytes = loadClassBytes(name);
  37. } catch (Exception e) {
  38. throw new ClassNotFoundException(name);
  39. }
  40.  
  41. Class<?> cl= defineClass(name, classBytes, 0, classBytes.length);
  42. if(cl == null) throw new ClassNotFoundException(name);
  43.  
  44. return cl;
  45. }
  46.  
  47. /**
  48. * 简单的解密
  49. * @param name
  50. * @return
  51. * @throws IOException
  52. */
  53. private byte[] loadClassBytes(String name) throws IOException{
  54. String cname = name.replace('.', '/') + ".class";
  55.  
  56. FileInputStream in = new FileInputStream(cname);
  57. try {
  58. ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  59.  
  60. int ch;
  61. while((ch = in.read()) != -1){
  62. if(cname.contains("uikoo9")){// 如果包含uikoo9说明是自己写的class,进行解密
  63. System.out.println("++");
  64. buffer.write((byte)(ch-2));
  65. }else{
  66. buffer.write((byte)ch);
  67. }
  68. }
  69. in.close();
  70.  
  71. return buffer.toByteArray();
  72. }finally{
  73. in.close();
  74. }
  75. }
  76. }

【加入到tomcat中】

1.网上

网上很多文章都问到tomcat怎么使用自己的classloader,但是说明白的几乎没有,

最后自己读了tomcat官网的文档,找到了答案,

地址:http://tomcat.apache.org/tomcat-6.0-doc/config/loader.html

2.方法

说简单点,就是在tomcat\conf\context.xml中添加以下这段代码:

  1. <Loader loaderClass="com.uikoo9.MyClassLoader"></Loader >

3.classloader

但是注意,这里的com.uikoo9.MyClassLoader并不是项目中的,

而是需要放到tomcat\lib下。

【新的问题】

1.这个自己写的classloader确实起作用的,但是问题也随之而来,

原来tomcat在调用classloader之前会调用一个自己的classparser类来对class文件进行解析

2.classparser

位于org\apache\tomcat\util\bcel\classfile下的ClassParser.java,

源代码:

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. package org.apache.tomcat.util.bcel.classfile;
  19.  
  20. import java.io.BufferedInputStream;
  21. import java.io.DataInputStream;
  22. import java.io.FileInputStream;
  23. import java.io.IOException;
  24. import java.io.InputStream;
  25. import java.util.zip.ZipEntry;
  26. import java.util.zip.ZipFile;
  27.  
  28. import org.apache.tomcat.util.bcel.Constants;
  29.  
  30. /**
  31. * Wrapper class that parses a given Java .class file. The method <A
  32. * href ="#parse">parse</A> returns a <A href ="JavaClass.html">
  33. * JavaClass</A> object on success. When an I/O error or an
  34. * inconsistency occurs an appropiate exception is propagated back to
  35. * the caller.
  36. *
  37. * The structure and the names comply, except for a few conveniences,
  38. * exactly with the <A href="ftp://java.sun.com/docs/specs/vmspec.ps">
  39. * JVM specification 1.0</a>. See this paper for
  40. * further details about the structure of a bytecode file.
  41. *
  42. * @version $Id: ClassParser.java 992409 2010-09-03 18:35:59Z markt $
  43. * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
  44. */
  45. public final class ClassParser {
  46.  
  47. private DataInputStream file;
  48. private boolean fileOwned;
  49. private String file_name;
  50. private String zip_file;
  51. private int class_name_index, superclass_name_index;
  52. private int major, minor; // Compiler version
  53. private int access_flags; // Access rights of parsed class
  54. private int[] interfaces; // Names of implemented interfaces
  55. private ConstantPool constant_pool; // collection of constants
  56. private Field[] fields; // class fields, i.e., its variables
  57. private Method[] methods; // methods defined in the class
  58. private Attribute[] attributes; // attributes defined in the class
  59. private boolean is_zip; // Loaded from zip file
  60. private static final int BUFSIZE = 8192;
  61.  
  62. /**
  63. * Parse class from the given stream.
  64. *
  65. * @param file Input stream
  66. * @param file_name File name
  67. */
  68. public ClassParser(InputStream file, String file_name) {
  69. this.file_name = file_name;
  70. fileOwned = false;
  71. String clazz = file.getClass().getName(); // Not a very clean solution ...
  72. is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar.");
  73. if (file instanceof DataInputStream) {
  74. this.file = (DataInputStream) file;
  75. } else {
  76. this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE));
  77. }
  78. }
  79.  
  80. /**
  81. * Parse the given Java class file and return an object that represents
  82. * the contained data, i.e., constants, methods, fields and commands.
  83. * A <em>ClassFormatException</em> is raised, if the file is not a valid
  84. * .class file. (This does not include verification of the byte code as it
  85. * is performed by the java interpreter).
  86. *
  87. * @return Class object representing the parsed class file
  88. * @throws IOException
  89. * @throws ClassFormatException
  90. */
  91. public JavaClass parse() throws IOException, ClassFormatException {
  92. ZipFile zip = null;
  93. try {
  94. if (fileOwned) {
  95. if (is_zip) {
  96. zip = new ZipFile(zip_file);
  97. ZipEntry entry = zip.getEntry(file_name);
  98.  
  99. if (entry == null) {
  100. throw new IOException("File " + file_name + " not found");
  101. }
  102.  
  103. file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry),
  104. BUFSIZE));
  105. } else {
  106. file = new DataInputStream(new BufferedInputStream(new FileInputStream(
  107. file_name), BUFSIZE));
  108. }
  109. }
  110. /****************** Read headers ********************************/
  111. // Check magic tag of class file
  112. readID();
  113. // Get compiler version
  114. readVersion();
  115. /****************** Read constant pool and related **************/
  116. // Read constant pool entries
  117. readConstantPool();
  118. // Get class information
  119. readClassInfo();
  120. // Get interface information, i.e., implemented interfaces
  121. readInterfaces();
  122. /****************** Read class fields and methods ***************/
  123. // Read class fields, i.e., the variables of the class
  124. readFields();
  125. // Read class methods, i.e., the functions in the class
  126. readMethods();
  127. // Read class attributes
  128. readAttributes();
  129. // Check for unknown variables
  130. //Unknown[] u = Unknown.getUnknownAttributes();
  131. //for(int i=0; i < u.length; i++)
  132. // System.err.println("WARNING: " + u[i]);
  133. // Everything should have been read now
  134. // if(file.available() > 0) {
  135. // int bytes = file.available();
  136. // byte[] buf = new byte[bytes];
  137. // file.read(buf);
  138. // if(!(is_zip && (buf.length == 1))) {
  139. // System.err.println("WARNING: Trailing garbage at end of " + file_name);
  140. // System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf));
  141. // }
  142. // }
  143. } finally {
  144. // Read everything of interest, so close the file
  145. if (fileOwned) {
  146. try {
  147. if (file != null) {
  148. file.close();
  149. }
  150. if (zip != null) {
  151. zip.close();
  152. }
  153. } catch (IOException ioe) {
  154. //ignore close exceptions
  155. }
  156. }
  157. }
  158. // Return the information we have gathered in a new object
  159. return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor,
  160. access_flags, constant_pool, interfaces, fields, methods, attributes);
  161. }
  162.  
  163. /**
  164. * Read information about the attributes of the class.
  165. * @throws IOException
  166. * @throws ClassFormatException
  167. */
  168. private final void readAttributes() throws IOException, ClassFormatException {
  169. int attributes_count;
  170. attributes_count = file.readUnsignedShort();
  171. attributes = new Attribute[attributes_count];
  172. for (int i = 0; i < attributes_count; i++) {
  173. attributes[i] = Attribute.readAttribute(file, constant_pool);
  174. }
  175. }
  176.  
  177. /**
  178. * Read information about the class and its super class.
  179. * @throws IOException
  180. * @throws ClassFormatException
  181. */
  182. private final void readClassInfo() throws IOException, ClassFormatException {
  183. access_flags = file.readUnsignedShort();
  184. /* Interfaces are implicitely abstract, the flag should be set
  185. * according to the JVM specification.
  186. */
  187. if ((access_flags & Constants.ACC_INTERFACE) != 0) {
  188. access_flags |= Constants.ACC_ABSTRACT;
  189. }
  190. if (((access_flags & Constants.ACC_ABSTRACT) != 0)
  191. && ((access_flags & Constants.ACC_FINAL) != 0)) {
  192. throw new ClassFormatException("Class " + file_name + " can't be both final and abstract");
  193. }
  194. class_name_index = file.readUnsignedShort();
  195. superclass_name_index = file.readUnsignedShort();
  196. }
  197.  
  198. /**
  199. * Read constant pool entries.
  200. * @throws IOException
  201. * @throws ClassFormatException
  202. */
  203. private final void readConstantPool() throws IOException, ClassFormatException {
  204. constant_pool = new ConstantPool(file);
  205. }
  206.  
  207. /**
  208. * Read information about the fields of the class, i.e., its variables.
  209. * @throws IOException
  210. * @throws ClassFormatException
  211. */
  212. private final void readFields() throws IOException, ClassFormatException {
  213. int fields_count;
  214. fields_count = file.readUnsignedShort();
  215. fields = new Field[fields_count];
  216. for (int i = 0; i < fields_count; i++) {
  217. fields[i] = new Field(file, constant_pool);
  218. }
  219. }
  220.  
  221. /******************** Private utility methods **********************/
  222. /**
  223. * Check whether the header of the file is ok.
  224. * Of course, this has to be the first action on successive file reads.
  225. * @throws IOException
  226. * @throws ClassFormatException
  227. */
  228. private final void readID() throws IOException, ClassFormatException {
  229. int magic = 0xCAFEBABE;
  230. if (file.readInt() != magic) {
  231. throw new ClassFormatException(file_name + " is not a Java .class file");
  232. }
  233. }
  234.  
  235. /**
  236. * Read information about the interfaces implemented by this class.
  237. * @throws IOException
  238. * @throws ClassFormatException
  239. */
  240. private final void readInterfaces() throws IOException, ClassFormatException {
  241. int interfaces_count;
  242. interfaces_count = file.readUnsignedShort();
  243. interfaces = new int[interfaces_count];
  244. for (int i = 0; i < interfaces_count; i++) {
  245. interfaces[i] = file.readUnsignedShort();
  246. }
  247. }
  248.  
  249. /**
  250. * Read information about the methods of the class.
  251. * @throws IOException
  252. * @throws ClassFormatException
  253. */
  254. private final void readMethods() throws IOException, ClassFormatException {
  255. int methods_count;
  256. methods_count = file.readUnsignedShort();
  257. methods = new Method[methods_count];
  258. for (int i = 0; i < methods_count; i++) {
  259. methods[i] = new Method(file, constant_pool);
  260. }
  261. }
  262.  
  263. /**
  264. * Read major and minor version of compiler which created the file.
  265. * @throws IOException
  266. * @throws ClassFormatException
  267. */
  268. private final void readVersion() throws IOException, ClassFormatException {
  269. minor = file.readUnsignedShort();
  270. major = file.readUnsignedShort();
  271. }
  272. }

3.问题

发现这个解析类的文件会先去判断class的头信息来确定是不是class文件,

但是由于我们对class进行了加密,所以头信息变了,所以这个解析class文件的类会报错,也就不会调用到classloader了

【继续】

文章有点长,不知道有人有耐心看完不。

1.上面的问题折腾了一天,才发现是自己解密的部分有问题,

2.不过也是有收获的,发现自定写的loader只能加载非class的文件,而不能加载class

3.意思就是说,你需要将原来的class文件加密并改变文件后缀,然后配合自己的loader使用

【delegate】

由于自己英语水平有限,所以之前的tomcat文章一知半解,

通过今天的研究发现context.xml中的delegate属性的用法。

1.loader的代码:

  1. package com.uikoo9.loader;
  2.  
  3. import java.io.ByteArrayOutputStream;
  4. import java.io.FileInputStream;
  5. import java.io.IOException;
  6.  
  7. import org.apache.catalina.loader.WebappClassLoader;
  8.  
  9. /**
  10. * 自定义的classloader
  11. * 可以解密文件并加载
  12. * @author uikoo9
  13. */
  14. public class UClassLoader extends WebappClassLoader{
  15.  
  16. /**
  17. * 默认构造器
  18. */
  19. public UClassLoader() {
  20. super();
  21. }
  22.  
  23. /**
  24. * 默认构造器
  25. * @param parent
  26. */
  27. public UClassLoader(ClassLoader parent) {
  28. super(parent);
  29. }
  30.  
  31. /* (non-Javadoc)
  32. * @see org.apache.catalina.loader.WebappClassLoader#findClass(java.lang.String)
  33. */
  34. public Class<?> findClass(String name) throws ClassNotFoundException {
  35. byte[] classBytes = null;
  36. try {
  37. if(name.contains("uikoo9")){
  38. System.out.println("++++++" + name);
  39. classBytes = loadClassBytesEncrypt(name);
  40. }else{
  41. System.out.println("-------" + name);
  42. classBytes = loadClassBytesDefault(name);
  43. }
  44. } catch (Exception e) {
  45. e.printStackTrace();
  46. }
  47.  
  48. Class<?> cl = defineClass(name, classBytes, 0, classBytes.length);
  49. if (cl == null)
  50. throw new ClassNotFoundException(name);
  51. return cl;
  52. }
  53.  
  54. @Override
  55. public Class<?> loadClass(String name) throws ClassNotFoundException {
  56. if(name.contains("uikoo9")){
  57. return findClass(name);
  58. }else{
  59. return super.loadClass(name);
  60. }
  61. }
  62.  
  63. /**
  64. * 加载加密后的class字节流
  65. * @param name
  66. * @return
  67. * @throws IOException
  68. */
  69. private byte[] loadClassBytesEncrypt(String name) throws IOException {
  70. String cname = name.replace('.', '/') + ".uikoo9";
  71. FileInputStream in = null;
  72. in = new FileInputStream(cname);
  73. try {
  74. ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  75. int ch;
  76. while ((ch = in.read()) != -1) {
  77. buffer.write((byte)(ch - 2));
  78. }
  79. in.close();
  80. return buffer.toByteArray();
  81. } finally {
  82. in.close();
  83. }
  84. }
  85.  
  86. /**
  87. * 加载普通的class字节流
  88. * @param name
  89. * @return
  90. * @throws IOException
  91. */
  92. private byte[] loadClassBytesDefault(String name) throws IOException {
  93. String cname = name.replace('.', '/') + ".class";
  94. FileInputStream in = null;
  95. in = new FileInputStream(cname);
  96. try {
  97. ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  98. int ch;
  99. while ((ch = in.read()) != -1) {
  100. buffer.write((byte)ch);
  101. }
  102. in.close();
  103. return buffer.toByteArray();
  104. } finally {
  105. in.close();
  106. }
  107. }
  108. }

2.delegate="false"时,启动tomcat:

  1. <Loader loaderClass="com.uikoo9.loader.UClassLoader" delegate="false"></Loader >

3.delegate="true"时,启动tomcat:

  1. <Loader loaderClass="com.uikoo9.loader.UClassLoader" delegate="true"></Loader >

4.总结

delegate为true的时候自定义的loader只用来加载自己的代码

【新问题】

以上的代码整理一下,启动tomcat,没有报错,

但是当点击页面的时候,也就是向后台请求的时候依然报错,

【end】

经过中午的挣扎,这个问题终于解决了,

注意,这个只适合没有spring的,因为spring有自己的classloader。

【classloader】

1.代码:

  1. import java.io.ByteArrayOutputStream;
  2. import java.io.FileInputStream;
  3. import java.io.IOException;
  4.  
  5. import org.apache.catalina.loader.WebappClassLoader;
  6.  
  7. /**
  8. * 自定义的classloader
  9. * 可以解密文件并加载
  10. * @author uikoo9
  11. */
  12. public class UClassLoader extends WebappClassLoader{
  13.  
  14. /**
  15. * 默认构造器
  16. */
  17. public UClassLoader() {
  18. super();
  19. }
  20.  
  21. /**
  22. * 默认构造器
  23. * @param parent
  24. */
  25. public UClassLoader(ClassLoader parent) {
  26. super(parent);
  27. }
  28.  
  29. /* (non-Javadoc)
  30. * @see org.apache.catalina.loader.WebappClassLoader#findClass(java.lang.String)
  31. */
  32. public Class<?> findClass(String name) throws ClassNotFoundException {
  33. if(name.contains("uikoo9")){
  34. return findClassEncrypt(name);
  35. }else{
  36. return super.findClass(name);
  37. }
  38. }
  39.  
  40. /**
  41. * 查找class
  42. * @param name
  43. * @return
  44. * @throws ClassNotFoundException
  45. */
  46. private Class<?> findClassEncrypt(String name) throws ClassNotFoundException{
  47. byte[] classBytes = null;
  48. try {
  49. System.out.println("++++++" + name);
  50. classBytes = loadClassBytesEncrypt(name);
  51. } catch (Exception e) {
  52. e.printStackTrace();
  53. }
  54.  
  55. Class<?> cl = defineClass(name, classBytes, 0, classBytes.length);
  56. if (cl == null)
  57. throw new ClassNotFoundException(name);
  58. return cl;
  59. }
  60.  
  61. /**
  62. * 加载加密后的class字节流
  63. * @param name
  64. * @return
  65. * @throws IOException
  66. */
  67. private byte[] loadClassBytesEncrypt(String name) throws IOException {
  68. String basepath = "Z:/program/workspaces/_work_03_bzb/WebRoot/WEB-INF/classes/";// 项目物理地址
  69. String cname = basepath + name.replace('.', '/') + ".uikoo9";
  70. System.out.println(cname);
  71. FileInputStream in = new FileInputStream(cname);
  72. try {
  73. ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  74. int ch;
  75. while ((ch = in.read()) != -1) {
  76. buffer.write((byte)(ch - 2));
  77. }
  78. in.close();
  79. return buffer.toByteArray();
  80. } finally {
  81. in.close();
  82. }
  83. }
  84. }

【加入到tomcat】

1.context.xml

找到tomcat下contex.xml,在context之间加入以下代码:

  1. <Loader loaderClass="com.uikoo9.loader.UClassLoader" delegate="true"></Loader>

其中loaderClass就是自己写loader,delegate=“true”的意思是只解密非系统的class和jar

2.添加loader

将自己写的loader的class文件放到tomcat\lib下

【开始】

1.使用加密程序对classes下所有文件加密,加密之后所有的class文件后缀变为uikoo9,可以自己修改源代码

2.将原classes文件夹删除,将加密后的classes文件夹复制进去

3.修改context.xml

4.tomcat\lib下添加loader.class

5.启动tomcat

原文:http://blog.csdn.net/uikoo9/article/details/17281403

Tomcat自定义classLoader加密解密的更多相关文章

  1. SpringBoot自定义classloader加密保护class文件

    背景 最近针对公司框架进行关键业务代码进行加密处理,防止通过jd-gui等反编译工具能够轻松还原工程代码,相关混淆方案配置使用比较复杂且针对springboot项目问题较多,所以针对class文件加密 ...

  2. 推荐分享一个牛X的自定义PHP加密解密类

    通俗点说,用它来进行加密,同一个字符串,每次进行加密,得出的结果都是不一样的,大大加强了数据安全性.同时还可设定加密后数据的有效期,简直牛掰了 #食用方法 将下面的第二份模块代码保存为 Mcrypt. ...

  3. Net Core 自定义 Middleware 加密解密

    前言:第一次写文章,有问题请轻喷 当前使用 Net Core 版本 2.1.3 我们经常在开发中需要把实体的主键 Id 传输到前端,但是在Get的时候又不想让前端能看到明文,我们通常会加密这些数据,所 ...

  4. 解决自定义classloader后无法使用maven install

    @上篇博客中探讨了web项目利用自定义classloader进行解密,利用的是编译后的文件直接运行程序一切正常 今天博主在探讨加密后进行混淆时,打包程序报程序包org.apache.catalina. ...

  5. PHP DES加密解密

    自定义密码加密解密函数,源自网友,记录保存一下. <?php /** * DES加密解密 */ class Mcrypt{ public function __construct(){} fun ...

  6. JAVA 利用JNI加密class文件/自定义ClassLoader 类

    利用 JNI 对bytecode 加密.不影响java程序员的正常开发.09年的时候写的,现在拿出来晒晒————————————————————————————混淆才是王道,如果混淆再加密就更酷了.. ...

  7. Laravel之加密解密/日志/异常处理及自定义错误

    一.加密解密 1.加密Crypt::encrypt($request->secret) 2.解密try { $decrypted = Crypt::decrypt($encryptedValue ...

  8. 【转】asp.net(c#)加密解密算法之sha1、md5、des、aes实现源码详解

    原文地址:http://docode.top/Article/Detail/10003 目录: 1..Net(C#)平台下Des加密解密源代码 2..Net(C#)平台下Aes加密解密源代码 3..N ...

  9. 基于正则的INI读写工具类,支持加密解密

    看到这个标题,有人会问,现在都用xml做配置文件了,谁还用INI文件啊!下面来简单对比一下xml和ini: 1.XML功能强大表达能力强,同时扩展性好. 2.它的主要优势是异构平台的整合.通讯. 3. ...

随机推荐

  1. SpringMVC学习(一):搭建SpringMVC-注解-非注解

    文章参考:http://www.cnblogs.com/Sinte-Beuve/p/5730553.html 一.环境搭建: 目录结构: 引用的JAR包: 如果是Maven搭建的话pom.xml配置依 ...

  2. HTML marquee标签

    marquee语法    <marquee></marquee> 实例一<marquee>Hello, World</marquee> marquee常 ...

  3. HTML5即将迎来黄金时代 轻应用再成行业焦点

    2015-01-23 11:03:09     来源:快鲤鱼 大众能看到的H5效果拜“微信”所赐,几乎每天都有H5页面的推广以及H5小游戏在微信上传播.其实,H5的大热与百度不无关系,2012年开始, ...

  4. 【上】安全HTTPS-全面具体解释对称加密,非对称加密,数字签名,数字证书和HTTPS

    一,对称加密 所谓对称加密.就是它们在编码时使用的密钥e和解码时一样d(e=d),我们就将其统称为密钥k. 对称加解密的步骤例如以下: 发送端和接收端首先要共享同样的密钥k(即通信前两方都须要知道相应 ...

  5. 多线程(C++)临界区Critical Sections

    一 .Critical Sections(功能与Mutex相同,保证某一时刻只有一个线程能够访问共享资源,但是不是内核对象,所以访问速度比Mutex快,但是没有等待超时的功能,所以有可能导致死锁,使用 ...

  6. python2&python3的区别

    区别1. python3中>>>range<3,6>range<3,6> python2中>>>range<3,6>[3,4,5 ...

  7. xorm

    https://github.com/go-xorm/xorm Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3, ...

  8. JSOI2004 平衡点 / 吊打XXX

    题目描述 有n个重物,每个重物系在一条足够长的绳子上.每条绳子自上而下穿过桌面上的洞,然后系在一起.图中X处就是公共的绳结.假设绳子是完全弹性的(不会造成能量损失),桌子足够高(因而重物不会垂到地上) ...

  9. Linux常用命令——持续更新(2018-05-09)

    此命令默认是在centos环境下执行,除非特殊标明. 1.查看ip: ifconfig 2.创建指定用户并分配到某个组:创建用户user并分配到root组 useradd -g root user 3 ...

  10. javascript Date对象的介绍及linux时间戳如何在javascript中转化成标准时间格式

    1.Date对象介绍 Date对象具有多种构造函数.new Date()new Date(milliseconds)new Date(datestring)new Date(year, month)n ...