Java 中的加密
Encryption in Java
我有一个由代码生成的包含 10 个随机数的数组。有什么方法可以用 public 密钥加密数组,只有拥有相应私钥的用户才能解码和解密数组。
使用手机的 IMEI 号码生成密钥
cipher = Cipher.getInstance("AES");
SecretKeySpec spec = new SecretKeySpec("KeyOfSize16Leng.".getBytes("UTF-8"), "AES");
cipher.init(Cipher.DECRYPT_MODE, spec);
Secret Parameter required is of size 16 characters, so take substring of IMEI Number from 0 to 16 characters or if it is less than 16 characters then add any known character to the end till length becomes 16.
在服务器端和 android 端执行此步骤。
希望对您有所帮助。
我有一个由代码生成的包含 10 个随机数的数组。有什么方法可以用 public 密钥加密数组,只有拥有相应私钥的用户才能解码和解密数组。
使用手机的 IMEI 号码生成密钥
cipher = Cipher.getInstance("AES");
SecretKeySpec spec = new SecretKeySpec("KeyOfSize16Leng.".getBytes("UTF-8"), "AES");
cipher.init(Cipher.DECRYPT_MODE, spec);
Secret Parameter required is of size 16 characters, so take substring of IMEI Number from 0 to 16 characters or if it is less than 16 characters then add any known character to the end till length becomes 16.
在服务器端和 android 端执行此步骤。
希望对您有所帮助。