mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-06-20 22:17:09 +08:00
更新加密算法
This commit is contained in:
parent
d74612b492
commit
50aedd1d1b
@ -27,9 +27,9 @@ public class DesDemo {
|
|||||||
byte[] result;
|
byte[] result;
|
||||||
try {
|
try {
|
||||||
result = DesDemo.encrypt(str.getBytes(), password);
|
result = DesDemo.encrypt(str.getBytes(), password);
|
||||||
System.out.println("加密后:" + new String(result));
|
System.out.println("加密后:" + result);
|
||||||
byte[] decryResult = DesDemo.decrypt(result, password);
|
byte[] decryResult = DesDemo.decrypt(result, password);
|
||||||
System.out.println("解密后:" + new String(decryResult));
|
System.out.println("解密后:" + decryResult);
|
||||||
} catch (UnsupportedEncodingException e2) {
|
} catch (UnsupportedEncodingException e2) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e2.printStackTrace();
|
e2.printStackTrace();
|
||||||
|
@ -28,9 +28,9 @@ public class RSADemo {
|
|||||||
System.out.println("-----------------------------------");
|
System.out.println("-----------------------------------");
|
||||||
byte[] encryptByPrivateKey = encryptByPrivateKey("123456".getBytes(), privateKey);
|
byte[] encryptByPrivateKey = encryptByPrivateKey("123456".getBytes(), privateKey);
|
||||||
byte[] encryptByPublicKey = encryptByPublicKey("123456", publicKey);
|
byte[] encryptByPublicKey = encryptByPublicKey("123456", publicKey);
|
||||||
System.out.println(new String(encryptByPrivateKey));
|
System.out.println(encryptByPrivateKey);
|
||||||
System.out.println("-----------------------------------");
|
System.out.println("-----------------------------------");
|
||||||
System.out.println(new String(encryptByPublicKey));
|
System.out.println(encryptByPublicKey);
|
||||||
System.out.println("-----------------------------------");
|
System.out.println("-----------------------------------");
|
||||||
String sign = sign(encryptByPrivateKey, privateKey);
|
String sign = sign(encryptByPrivateKey, privateKey);
|
||||||
System.out.println(sign);
|
System.out.println(sign);
|
||||||
@ -40,9 +40,9 @@ public class RSADemo {
|
|||||||
System.out.println("-----------------------------------");
|
System.out.println("-----------------------------------");
|
||||||
byte[] decryptByPublicKey = decryptByPublicKey(encryptByPrivateKey, publicKey);
|
byte[] decryptByPublicKey = decryptByPublicKey(encryptByPrivateKey, publicKey);
|
||||||
byte[] decryptByPrivateKey = decryptByPrivateKey(encryptByPublicKey, privateKey);
|
byte[] decryptByPrivateKey = decryptByPrivateKey(encryptByPublicKey, privateKey);
|
||||||
System.out.println(new String(decryptByPublicKey));
|
System.out.println(decryptByPublicKey);
|
||||||
System.out.println("-----------------------------------");
|
System.out.println("-----------------------------------");
|
||||||
System.out.println(new String(decryptByPrivateKey));
|
System.out.println(decryptByPrivateKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user