小编Bas*_*saa的帖子

Java~通过套接字连接发送枚举

通过套接字发送枚举值的最佳方法是什么?有没有办法将枚举值转换为int,反之亦然?喜欢:

Enum values {
    value1,
    value2
}

int value = (int)value1;
And...
values value2 = (value) value;
Run Code Online (Sandbox Code Playgroud)

通过互联网发送这个会很高兴!谢谢大家!

巴斯

java sockets enums asynchronous tcp

6
推荐指数
1
解决办法
2298
查看次数

C#/Java | AES256 加密/解密

我想加密我通过 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)

c# java encryption aes

2
推荐指数
1
解决办法
7706
查看次数

标签 统计

java ×2

aes ×1

asynchronous ×1

c# ×1

encryption ×1

enums ×1

sockets ×1

tcp ×1