通过套接字发送枚举值的最佳方法是什么?有没有办法将枚举值转换为int,反之亦然?喜欢:
Enum values {
value1,
value2
}
int value = (int)value1;
And...
values value2 = (value) value;
Run Code Online (Sandbox Code Playgroud)
通过互联网发送这个会很高兴!谢谢大家!
巴斯
我想加密我通过 Java/C# 套接字(Java 服务器、C# 客户端)发送的所有数据。我想使用 AES256,但我无法让 Java 和 C# 生成相同的加密代码。谁能给我两个例子,1 个在 Java 中,1 个在 C# 中,它们生成相同的结果并正确解密结果?
到目前为止我尝试过的:
public Encrypt(AOBCore instance){
try {
String message="This is just an example";
// Get the KeyGenerator
KeyGenerator kgen = KeyGenerator.getInstance("AES");
kgen.init(256); // 192 and 256 bits may not be available
// Generate the secret key specs.
SecretKey skey = kgen.generateKey(); //Cantget 'test' in here...
byte[] raw = skey.getEncoded();
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
// Instantiate the cipher
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec); …Run Code Online (Sandbox Code Playgroud)