[022] Android、iPhone和Java三个平台一致的加密工具 .

2024-06-15 10:08

本文主要是介绍[022] Android、iPhone和Java三个平台一致的加密工具 .,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

先前一直在做安卓,最近要开发iPhone客户端,这其中遇到的 最让人纠结的要属Java、Android和iPhone三个平台加解密不一致的问题。因为手机端后台通常是用JAVA开发的Web Service,Android和iPhone客户端调用同样的Web Service接口,为了数据安全考虑,要对数据进行加密。头疼的问题就来了,很难编写出一套加密程序,在3个平台间加解密的结果一致,总不能为Android和iPhone两个客户端各写一套Web Service接口吧?我相信还会有很多朋友为此困惑, 在此分享一套3DES加密程序,能够实现Java、Android和iPhone三个平台加解密一致

        首先是JAVA端的加密工具类,它同样适用于Android端,无需任何修改,即可保证Java与Android端的加解密一致,并且中文不会乱码。

[java] view plain copy print ?
  1. package org.liuyq.des3;  
  2.   
  3. import java.security.Key;  
  4.   
  5. import javax.crypto.Cipher;  
  6. import javax.crypto.SecretKeyFactory;  
  7. import javax.crypto.spec.DESedeKeySpec;  
  8. import javax.crypto.spec.IvParameterSpec;  
  9.   
  10. /** 
  11.  * 3DES加密工具类 
  12.  *  
  13.  * @author liufeng  
  14.  * @date 2012-10-11 
  15.  */  
  16. public class Des3 {  
  17.     // 密钥   
  18.     private final static String secretKey = "liuyunqiang@lx100$#365#$";  
  19.     // 向量   
  20.     private final static String iv = "01234567";  
  21.     // 加解密统一使用的编码方式   
  22.     private final static String encoding = "utf-8";  
  23.   
  24.     /** 
  25.      * 3DES加密 
  26.      *  
  27.      * @param plainText 普通文本 
  28.      * @return 
  29.      * @throws Exception  
  30.      */  
  31.     public static String encode(String plainText) throws Exception {  
  32.         Key deskey = null;  
  33.         DESedeKeySpec spec = new DESedeKeySpec(secretKey.getBytes());  
  34.         SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede");  
  35.         deskey = keyfactory.generateSecret(spec);  
  36.   
  37.         Cipher cipher = Cipher.getInstance("desede/CBC/PKCS5Padding");  
  38.         IvParameterSpec ips = new IvParameterSpec(iv.getBytes());  
  39.         cipher.init(Cipher.ENCRYPT_MODE, deskey, ips);  
  40.         byte[] encryptData = cipher.doFinal(plainText.getBytes(encoding));  
  41.         return Base64.encode(encryptData);  
  42.     }  
  43.   
  44.     /** 
  45.      * 3DES解密 
  46.      *  
  47.      * @param encryptText 加密文本 
  48.      * @return 
  49.      * @throws Exception 
  50.      */  
  51.     public static String decode(String encryptText) throws Exception {  
  52.         Key deskey = null;  
  53.         DESedeKeySpec spec = new DESedeKeySpec(secretKey.getBytes());  
  54.         SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede");  
  55.         deskey = keyfactory.generateSecret(spec);  
  56.         Cipher cipher = Cipher.getInstance("desede/CBC/PKCS5Padding");  
  57.         IvParameterSpec ips = new IvParameterSpec(iv.getBytes());  
  58.         cipher.init(Cipher.DECRYPT_MODE, deskey, ips);  
  59.   
  60.         byte[] decryptData = cipher.doFinal(Base64.decode(encryptText));  
  61.   
  62.         return new String(decryptData, encoding);  
  63.     }  
  64. }  
package org.liuyq.des3;
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.IvParameterSpec;
/**
* 3DES加密工具类
* 
* @author liufeng 
* @date 2012-10-11
*/
public class Des3 {
// 密钥
private final static String secretKey = "liuyunqiang@lx100$#365#$";
// 向量
private final static String iv = "01234567";
// 加解密统一使用的编码方式
private final static String encoding = "utf-8";
/**
* 3DES加密
* 
* @param plainText 普通文本
* @return
* @throws Exception 
*/
public static String encode(String plainText) throws Exception {
Key deskey = null;
DESedeKeySpec spec = new DESedeKeySpec(secretKey.getBytes());
SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede");
deskey = keyfactory.generateSecret(spec);
Cipher cipher = Cipher.getInstance("desede/CBC/PKCS5Padding");
IvParameterSpec ips = new IvParameterSpec(iv.getBytes());
cipher.init(Cipher.ENCRYPT_MODE, deskey, ips);
byte[] encryptData = cipher.doFinal(plainText.getBytes(encoding));
return Base64.encode(encryptData);
}
/**
* 3DES解密
* 
* @param encryptText 加密文本
* @return
* @throws Exception
*/
public static String decode(String encryptText) throws Exception {
Key deskey = null;
DESedeKeySpec spec = new DESedeKeySpec(secretKey.getBytes());
SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede");
deskey = keyfactory.generateSecret(spec);
Cipher cipher = Cipher.getInstance("desede/CBC/PKCS5Padding");
IvParameterSpec ips = new IvParameterSpec(iv.getBytes());
cipher.init(Cipher.DECRYPT_MODE, deskey, ips);
byte[] decryptData = cipher.doFinal(Base64.decode(encryptText));
return new String(decryptData, encoding);
}
}

        上面的加密工具类会使用到Base64这个类,该类的源代码如下:

[java] view plain copy print ?
  1. package org.liuyq.des3;  
  2. import java.io.ByteArrayOutputStream;  
  3. import java.io.IOException;  
  4. import java.io.OutputStream;  
  5.   
  6. /** 
  7.  * Base64编码工具类 
  8.  *  
  9.  * @author liufeng  
  10.  * @date 2012-10-11 
  11.  */  
  12. public class Base64 {  
  13.     private static final char[] legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();  
  14.   
  15.     public static String encode(byte[] data) {  
  16.         int start = 0;  
  17.         int len = data.length;  
  18.         StringBuffer buf = new StringBuffer(data.length * 3 / 2);  
  19.   
  20.         int end = len - 3;  
  21.         int i = start;  
  22.         int n = 0;  
  23.   
  24.         while (i <= end) {  
  25.             int d = ((((int) data[i]) & 0x0ff) << 16) | ((((int) data[i + 1]) & 0x0ff) << 8) | (((int) data[i + 2]) & 0x0ff);  
  26.   
  27.             buf.append(legalChars[(d >> 18) & 63]);  
  28.             buf.append(legalChars[(d >> 12) & 63]);  
  29.             buf.append(legalChars[(d >> 6) & 63]);  
  30.             buf.append(legalChars[d & 63]);  
  31.   
  32.             i += 3;  
  33.   
  34.             if (n++ >= 14) {  
  35.                 n = 0;  
  36.                 buf.append(" ");  
  37.             }  
  38.         }  
  39.   
  40.         if (i == start + len - 2) {  
  41.             int d = ((((int) data[i]) & 0x0ff) << 16) | ((((int) data[i + 1]) & 255) << 8);  
  42.   
  43.             buf.append(legalChars[(d >> 18) & 63]);  
  44.             buf.append(legalChars[(d >> 12) & 63]);  
  45.             buf.append(legalChars[(d >> 6) & 63]);  
  46.             buf.append("=");  
  47.         } else if (i == start + len - 1) {  
  48.             int d = (((int) data[i]) & 0x0ff) << 16;  
  49.   
  50.             buf.append(legalChars[(d >> 18) & 63]);  
  51.             buf.append(legalChars[(d >> 12) & 63]);  
  52.             buf.append("==");  
  53.         }  
  54.   
  55.         return buf.toString();  
  56.     }  
  57.   
  58.     private static int decode(char c) {  
  59.         if (c >= 'A' && c <= 'Z')  
  60.             return ((int) c) - 65;  
  61.         else if (c >= 'a' && c <= 'z')  
  62.             return ((int) c) - 97 + 26;  
  63.         else if (c >= '0' && c <= '9')  
  64.             return ((int) c) - 48 + 26 + 26;  
  65.         else  
  66.             switch (c) {  
  67.             case '+':  
  68.                 return 62;  
  69.             case '/':  
  70.                 return 63;  
  71.             case '=':  
  72.                 return 0;  
  73.             default:  
  74.                 throw new RuntimeException("unexpected code: " + c);  
  75.             }  
  76.     }  
  77.   
  78.     /** 
  79.      * Decodes the given Base64 encoded String to a new byte array. The byte array holding the decoded data is returned. 
  80.      */  
  81.   
  82.     public static byte[] decode(String s) {  
  83.   
  84.         ByteArrayOutputStream bos = new ByteArrayOutputStream();  
  85.         try {  
  86.             decode(s, bos);  
  87.         } catch (IOException e) {  
  88.             throw new RuntimeException();  
  89.         }  
  90.         byte[] decodedBytes = bos.toByteArray();  
  91.         try {  
  92.             bos.close();  
  93.             bos = null;  
  94.         } catch (IOException ex) {  
  95.             System.err.println("Error while decoding BASE64: " + ex.toString());  
  96.         }  
  97.         return decodedBytes;  
  98.     }  
  99.   
  100.     private static void decode(String s, OutputStream os) throws IOException {  
  101.         int i = 0;  
  102.   
  103.         int len = s.length();  
  104.   
  105.         while (true) {  
  106.             while (i < len && s.charAt(i) <= ' ')  
  107.                 i++;  
  108.   
  109.             if (i == len)  
  110.                 break;  
  111.   
  112.             int tri = (decode(s.charAt(i)) << 18) + (decode(s.charAt(i + 1)) << 12) + (decode(s.charAt(i + 2)) << 6) + (decode(s.charAt(i + 3)));  
  113.   
  114.             os.write((tri >> 16) & 255);  
  115.             if (s.charAt(i + 2) == '=')  
  116.                 break;  
  117.             os.write((tri >> 8) & 255);  
  118.             if (s.charAt(i + 3) == '=')  
  119.                 break;  
  120.             os.write(tri & 255);  
  121.   
  122.             i += 4;  
  123.         }  
  124.     }  
  125. }  
package org.liuyq.des3;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Base64编码工具类
* 
* @author liufeng 
* @date 2012-10-11
*/
public class Base64 {
private static final char[] legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
public static String encode(byte[] data) {
int start = 0;
int len = data.length;
StringBuffer buf = new StringBuffer(data.length * 3 / 2);
int end = len - 3;
int i = start;
int n = 0;
while (i <= end) {
int d = ((((int) data[i]) & 0x0ff) << 16) | ((((int) data[i + 1]) & 0x0ff) << 8) | (((int) data[i + 2]) & 0x0ff);
buf.append(legalChars[(d >> 18) & 63]);
buf.append(legalChars[(d >> 12) & 63]);
buf.append(legalChars[(d >> 6) & 63]);
buf.append(legalChars[d & 63]);
i += 3;
if (n++ >= 14) {
n = 0;
buf.append(" ");
}
}
if (i == start + len - 2) {
int d = ((((int) data[i]) & 0x0ff) << 16) | ((((int) data[i + 1]) & 255) << 8);
buf.append(legalChars[(d >> 18) & 63]);
buf.append(legalChars[(d >> 12) & 63]);
buf.append(legalChars[(d >> 6) & 63]);
buf.append("=");
} else if (i == start + len - 1) {
int d = (((int) data[i]) & 0x0ff) << 16;
buf.append(legalChars[(d >> 18) & 63]);
buf.append(legalChars[(d >> 12) & 63]);
buf.append("==");
}
return buf.toString();
}
private static int decode(char c) {
if (c >= 'A' && c <= 'Z')
return ((int) c) - 65;
else if (c >= 'a' && c <= 'z')
return ((int) c) - 97 + 26;
else if (c >= '0' && c <= '9')
return ((int) c) - 48 + 26 + 26;
else
switch (c) {
case '+':
return 62;
case '/':
return 63;
case '=':
return 0;
default:
throw new RuntimeException("unexpected code: " + c);
}
}
/**
* Decodes the given Base64 encoded String to a new byte array. The byte array holding the decoded data is returned.
*/
public static byte[] decode(String s) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
decode(s, bos);
} catch (IOException e) {
throw new RuntimeException();
}
byte[] decodedBytes = bos.toByteArray();
try {
bos.close();
bos = null;
} catch (IOException ex) {
System.err.println("Error while decoding BASE64: " + ex.toString());
}
return decodedBytes;
}
private static void decode(String s, OutputStream os) throws IOException {
int i = 0;
int len = s.length();
while (true) {
while (i < len && s.charAt(i) <= ' ')
i++;
if (i == len)
break;
int tri = (decode(s.charAt(i)) << 18) + (decode(s.charAt(i + 1)) << 12) + (decode(s.charAt(i + 2)) << 6) + (decode(s.charAt(i + 3)));
os.write((tri >> 16) & 255);
if (s.charAt(i + 2) == '=')
break;
os.write((tri >> 8) & 255);
if (s.charAt(i + 3) == '=')
break;
os.write(tri & 255);
i += 4;
}
}
}

        接下来是iPhone端的加密程序,当然是用Ojbective-C写的3DES加密程序,源代码如下:

[plain] view plain copy print ?
  1. //  
  2. //  DES3Util.h  
  3. //  lx100-gz  
  4. //  
  5. //  Created by  柳峰 on 12-10-10.  
  6. //  Copyright 2012 http://blog.csdn.net/lyq8479. All rights reserved.  
  7. //  
  8.   
  9. #import <Foundation/Foundation.h>  
  10.   
  11.   
  12. @interface DES3Util : NSObject {  
  13.   
  14. }  
  15.   
  16. // 加密方法  
  17. + (NSString*)encrypt:(NSString*)plainText;  
  18.   
  19. // 解密方法  
  20. + (NSString*)decrypt:(NSString*)encryptText;  
  21.   
  22. @end  
//
//  DES3Util.h
//  lx100-gz
//
//  Created by  柳峰 on 12-10-10.
//  Copyright 2012 http://blog.csdn.net/lyq8479. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface DES3Util : NSObject {
}
// 加密方法
+ (NSString*)encrypt:(NSString*)plainText;
// 解密方法
+ (NSString*)decrypt:(NSString*)encryptText;
@end
[plain] view plain copy print ?
  1. //  
  2. //  DES3Util.m  
  3. //  lx100-gz  
  4. //  
  5. //  Created by  柳峰 on 12-9-17.  
  6. //  Copyright 2012 http://blog.csdn.net/lyq8479. All rights reserved.  
  7. //  
  8.   
  9. #import "DES3Util.h"  
  10. #import <CommonCrypto/CommonCryptor.h>  
  11. #import "GTMBase64.h"  
  12.   
  13. #define gkey            @"liuyunqiang@lx100$#365#$"  
  14. #define gIv             @"01234567"  
  15.   
  16. @implementation DES3Util  
  17.   
  18. // 加密方法  
  19. + (NSString*)encrypt:(NSString*)plainText {  
  20.     NSData* data = [plainText dataUsingEncoding:NSUTF8StringEncoding];  
  21.     size_t plainTextBufferSize = [data length];  
  22.     const void *vplainText = (const void *)[data bytes];  
  23.       
  24.     CCCryptorStatus ccStatus;  
  25.     uint8_t *bufferPtr = NULL;  
  26.     size_t bufferPtrSize = 0;  
  27.     size_t movedBytes = 0;  
  28.       
  29.     bufferPtrSize = (plainTextBufferSize + kCCBlockSize3DES) & ~(kCCBlockSize3DES - 1);  
  30.     bufferPtr = malloc( bufferPtrSize * sizeof(uint8_t));  
  31.     memset((void *)bufferPtr, 0x0, bufferPtrSize);  
  32.       
  33.     const void *vkey = (const void *) [gkey UTF8String];  
  34.     const void *vinitVec = (const void *) [gIv UTF8String];  
  35.       
  36.     ccStatus = CCCrypt(kCCEncrypt,  
  37.                        kCCAlgorithm3DES,  
  38.                        kCCOptionPKCS7Padding,  
  39.                        vkey,  
  40.                        kCCKeySize3DES,  
  41.                        vinitVec,  
  42.                        vplainText,  
  43.                        plainTextBufferSize,  
  44.                        (void *)bufferPtr,  
  45.                        bufferPtrSize,  
  46.                        &movedBytes);  
  47.       
  48.     NSData *myData = [NSData dataWithBytes:(const void *)bufferPtr length:(NSUInteger)movedBytes];  
  49.     NSString *result = [GTMBase64 stringByEncodingData:myData];  
  50.     return result;  
  51. }  
  52.   
  53. // 解密方法  
  54. + (NSString*)decrypt:(NSString*)encryptText {  
  55.     NSData *encryptData = [GTMBase64 decodeData:[encryptText dataUsingEncoding:NSUTF8StringEncoding]];  
  56.     size_t plainTextBufferSize = [encryptData length];  
  57.     const void *vplainText = [encryptData bytes];  
  58.       
  59.     CCCryptorStatus ccStatus;  
  60.     uint8_t *bufferPtr = NULL;  
  61.     size_t bufferPtrSize = 0;  
  62.     size_t movedBytes = 0;  
  63.       
  64.     bufferPtrSize = (plainTextBufferSize + kCCBlockSize3DES) & ~(kCCBlockSize3DES - 1);  
  65.     bufferPtr = malloc( bufferPtrSize * sizeof(uint8_t));  
  66.     memset((void *)bufferPtr, 0x0, bufferPtrSize);  
  67.       
  68.     const void *vkey = (const void *) [gkey UTF8String];  
  69.     const void *vinitVec = (const void *) [gIv UTF8String];  
  70.       
  71.     ccStatus = CCCrypt(kCCDecrypt,  
  72.                        kCCAlgorithm3DES,  
  73.                        kCCOptionPKCS7Padding,  
  74.                        vkey,  
  75.                        kCCKeySize3DES,  
  76.                        vinitVec,  
  77.                        vplainText,  
  78.                        plainTextBufferSize,  
  79.                        (void *)bufferPtr,  
  80.                        bufferPtrSize,  
  81.                        &movedBytes);  
  82.       
  83.     NSString *result = [[[NSString alloc] initWithData:[NSData dataWithBytes:(const void *)bufferPtr   
  84.                                 length:(NSUInteger)movedBytes] encoding:NSUTF8StringEncoding] autorelease];  
  85.     return result;  
  86. }  
  87.   
  88. @end  
//
//  DES3Util.m
//  lx100-gz
//
//  Created by  柳峰 on 12-9-17.
//  Copyright 2012 http://blog.csdn.net/lyq8479. All rights reserved.
//
#import "DES3Util.h"
#import <CommonCrypto/CommonCryptor.h>
#import "GTMBase64.h"
#define gkey			@"liuyunqiang@lx100$#365#$"
#define gIv             @"01234567"
@implementation DES3Util
// 加密方法
+ (NSString*)encrypt:(NSString*)plainText {
NSData* data = [plainText dataUsingEncoding:NSUTF8StringEncoding];
size_t plainTextBufferSize = [data length];
const void *vplainText = (const void *)[data bytes];
CCCryptorStatus ccStatus;
uint8_t *bufferPtr = NULL;
size_t bufferPtrSize = 0;
size_t movedBytes = 0;
bufferPtrSize = (plainTextBufferSize + kCCBlockSize3DES) & ~(kCCBlockSize3DES - 1);
bufferPtr = malloc( bufferPtrSize * sizeof(uint8_t));
memset((void *)bufferPtr, 0x0, bufferPtrSize);
const void *vkey = (const void *) [gkey UTF8String];
const void *vinitVec = (const void *) [gIv UTF8String];
ccStatus = CCCrypt(kCCEncrypt,
kCCAlgorithm3DES,
kCCOptionPKCS7Padding,
vkey,
kCCKeySize3DES,
vinitVec,
vplainText,
plainTextBufferSize,
(void *)bufferPtr,
bufferPtrSize,
&movedBytes);
NSData *myData = [NSData dataWithBytes:(const void *)bufferPtr length:(NSUInteger)movedBytes];
NSString *result = [GTMBase64 stringByEncodingData:myData];
return result;
}
// 解密方法
+ (NSString*)decrypt:(NSString*)encryptText {
NSData *encryptData = [GTMBase64 decodeData:[encryptText dataUsingEncoding:NSUTF8StringEncoding]];
size_t plainTextBufferSize = [encryptData length];
const void *vplainText = [encryptData bytes];
CCCryptorStatus ccStatus;
uint8_t *bufferPtr = NULL;
size_t bufferPtrSize = 0;
size_t movedBytes = 0;
bufferPtrSize = (plainTextBufferSize + kCCBlockSize3DES) & ~(kCCBlockSize3DES - 1);
bufferPtr = malloc( bufferPtrSize * sizeof(uint8_t));
memset((void *)bufferPtr, 0x0, bufferPtrSize);
const void *vkey = (const void *) [gkey UTF8String];
const void *vinitVec = (const void *) [gIv UTF8String];
ccStatus = CCCrypt(kCCDecrypt,
kCCAlgorithm3DES,
kCCOptionPKCS7Padding,
vkey,
kCCKeySize3DES,
vinitVec,
vplainText,
plainTextBufferSize,
(void *)bufferPtr,
bufferPtrSize,
&movedBytes);
NSString *result = [[[NSString alloc] initWithData:[NSData dataWithBytes:(const void *)bufferPtr 
length:(NSUInteger)movedBytes] encoding:NSUTF8StringEncoding] autorelease];
return result;
}
@end

        iPhone端的加密工具类中引入了“GTMBase64.h”,这是iOS平台的Base64编码工具类,就不在这里贴出相关代码了,需要的百度一下就能找到,实在找不到就回复留言给我。

        好了,赶紧试一下吧,JAVA,Android和iPhone三个平台的加密不一致问题是不是解决了呢?其实,对此问题,还有一种更好的实现方式,那就是用C语言写一套加密程序,这样在iOS平台是可以直接使用C程序的,而在Java和Android端通过JNI去调用C语言编写的加密方法,这是不是就实现了3个平台调用同一套加密程序呢?

这篇关于[022] Android、iPhone和Java三个平台一致的加密工具 .的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1063152

相关文章

Java实现删除文件中的指定内容

《Java实现删除文件中的指定内容》在日常开发中,经常需要对文本文件进行批量处理,其中,删除文件中指定内容是最常见的需求之一,下面我们就来看看如何使用java实现删除文件中的指定内容吧... 目录1. 项目背景详细介绍2. 项目需求详细介绍2.1 功能需求2.2 非功能需求3. 相关技术详细介绍3.1 Ja

springboot项目中整合高德地图的实践

《springboot项目中整合高德地图的实践》:本文主要介绍springboot项目中整合高德地图的实践,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一:高德开放平台的使用二:创建数据库(我是用的是mysql)三:Springboot所需的依赖(根据你的需求再

spring中的ImportSelector接口示例详解

《spring中的ImportSelector接口示例详解》Spring的ImportSelector接口用于动态选择配置类,实现条件化和模块化配置,关键方法selectImports根据注解信息返回... 目录一、核心作用二、关键方法三、扩展功能四、使用示例五、工作原理六、应用场景七、自定义实现Impor

SpringBoot3应用中集成和使用Spring Retry的实践记录

《SpringBoot3应用中集成和使用SpringRetry的实践记录》SpringRetry为SpringBoot3提供重试机制,支持注解和编程式两种方式,可配置重试策略与监听器,适用于临时性故... 目录1. 简介2. 环境准备3. 使用方式3.1 注解方式 基础使用自定义重试策略失败恢复机制注意事项

SQLite3命令行工具最佳实践指南

《SQLite3命令行工具最佳实践指南》SQLite3是轻量级嵌入式数据库,无需服务器支持,具备ACID事务与跨平台特性,适用于小型项目和学习,sqlite3.exe作为命令行工具,支持SQL执行、数... 目录1. SQLite3简介和特点2. sqlite3.exe使用概述2.1 sqlite3.exe

SpringBoot整合Flowable实现工作流的详细流程

《SpringBoot整合Flowable实现工作流的详细流程》Flowable是一个使用Java编写的轻量级业务流程引擎,Flowable流程引擎可用于部署BPMN2.0流程定义,创建这些流程定义的... 目录1、流程引擎介绍2、创建项目3、画流程图4、开发接口4.1 Java 类梳理4.2 查看流程图4

一文详解如何在idea中快速搭建一个Spring Boot项目

《一文详解如何在idea中快速搭建一个SpringBoot项目》IntelliJIDEA作为Java开发者的‌首选IDE‌,深度集成SpringBoot支持,可一键生成项目骨架、智能配置依赖,这篇文... 目录前言1、创建项目名称2、勾选需要的依赖3、在setting中检查maven4、编写数据源5、开启热

Java对异常的认识与异常的处理小结

《Java对异常的认识与异常的处理小结》Java程序在运行时可能出现的错误或非正常情况称为异常,下面给大家介绍Java对异常的认识与异常的处理,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参... 目录一、认识异常与异常类型。二、异常的处理三、总结 一、认识异常与异常类型。(1)简单定义-什么是

SpringBoot项目配置logback-spring.xml屏蔽特定路径的日志

《SpringBoot项目配置logback-spring.xml屏蔽特定路径的日志》在SpringBoot项目中,使用logback-spring.xml配置屏蔽特定路径的日志有两种常用方式,文中的... 目录方案一:基础配置(直接关闭目标路径日志)方案二:结合 Spring Profile 按环境屏蔽关

基于Python实现一个Windows Tree命令工具

《基于Python实现一个WindowsTree命令工具》今天想要在Windows平台的CMD命令终端窗口中使用像Linux下的tree命令,打印一下目录结构层级树,然而还真有tree命令,但是发现... 目录引言实现代码使用说明可用选项示例用法功能特点添加到环境变量方法一:创建批处理文件并添加到PATH1