mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
removed unused static main in ConsoleProxyPasswordBasedEncryptor
This closes #11 This closes #10 This closes #176
This commit is contained in:
parent
02031aba69
commit
9be70843fd
@ -19,7 +19,6 @@ package com.cloud.servlet;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
@ -159,33 +158,4 @@ public class ConsoleProxyPasswordBasedEncryptor {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SecureRandom random;
|
||||
try {
|
||||
random = SecureRandom.getInstance("SHA1PRNG");
|
||||
byte[] keyBytes = new byte[16];
|
||||
random.nextBytes(keyBytes);
|
||||
|
||||
byte[] ivBytes = new byte[16];
|
||||
random.nextBytes(ivBytes);
|
||||
|
||||
KeyIVPair keyIvPair = new KeyIVPair("8x/xUBgX0Up+3UEo39dSeG277JhVj31+ElHkN5+EC0Q=", "Y2SUiIN6JXTdKNK/ZMDyVtLB7gAM9MCCiyrP1xd3bSQ=");
|
||||
//keyIvPair.setKeyBytes(keyBytes);
|
||||
//keyIvPair.setIvBytes(ivBytes);
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
ConsoleProxyPasswordBasedEncryptor encryptor = new ConsoleProxyPasswordBasedEncryptor(gson.toJson(keyIvPair));
|
||||
|
||||
String encrypted = encryptor.encryptText("Hello, world");
|
||||
|
||||
System.out.println("Encrypted result: " + encrypted);
|
||||
|
||||
String decrypted = encryptor.decryptText(encrypted);
|
||||
|
||||
System.out.println("Decrypted result: " + decrypted);
|
||||
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ package com.cloud.consoleproxy;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
@ -165,33 +164,4 @@ public class ConsoleProxyPasswordBasedEncryptor {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SecureRandom random;
|
||||
try {
|
||||
random = SecureRandom.getInstance("SHA1PRNG");
|
||||
byte[] keyBytes = new byte[16];
|
||||
random.nextBytes(keyBytes);
|
||||
|
||||
byte[] ivBytes = new byte[16];
|
||||
random.nextBytes(ivBytes);
|
||||
|
||||
KeyIVPair keyIvPair = new KeyIVPair("8x/xUBgX0Up+3UEo39dSeG277JhVj31+ElHkN5+EC0Q=", "Y2SUiIN6JXTdKNK/ZMDyVtLB7gAM9MCCiyrP1xd3bSQ=");
|
||||
//keyIvPair.setKeyBytes(keyBytes);
|
||||
//keyIvPair.setIvBytes(ivBytes);
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
ConsoleProxyPasswordBasedEncryptor encryptor = new ConsoleProxyPasswordBasedEncryptor(gson.toJson(keyIvPair));
|
||||
|
||||
String encrypted = encryptor.encryptText("Hello, world");
|
||||
|
||||
System.out.println("Encrypted result: " + encrypted);
|
||||
|
||||
String decrypted = encryptor.decryptText(encrypted);
|
||||
|
||||
System.out.println("Decrypted result: " + decrypted);
|
||||
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user