java加密方法如下:
Java code
String modeHex = "D548C6267CC503F1E926776A97F8644CAA67167E8FA5D74FD1F4E0BCB3608BD1583E41B102B5B4617E53B90A0C67EA652F8D96B40CFDDA6BC1501432ADCE15E4B5B916568893C94FF3CAC5ED5942FC604BAD1B12DF7683B25C6702BD8CF1BE2F5A4FFC97C82E42FD91E49A6EFF379F5F022F36E5395D64FC9430EEFCAC55F0A5";
String exponentHex = "10001";
KeyFactory factory = KeyFactory.getInstance("RSA");
BigInteger n = new BigInteger(modeHex, 16);
BigInteger e = new BigInteger(exponentHex, 16);
RSAPublicKeySpec spec = new RSAPublicKeySpec(n, e);
RSAPublicKey pub = (RSAPublicKey) factory.generatePublic(spec);
Cipher enc = Cipher.getInstance("RSA");
enc.init(Cipher.ENCRYPT_MODE, pub);
byte[] encryptedContentKey = enc.doFinal(messageg.getBytes("GB2312"));
String result = new String(Hex.encodeHex(encryptedContentKey));java加密方法如下:
Java code
String modeHex = "D548C6267CC503F1E926776A97F8644CAA67167E8FA5D74FD1F4E0BCB3608BD1583E41B102B5B4617E53B90A0C67EA652F8D96B40CFDDA6BC1501432ADCE15E4B5B916568893C94FF3CAC5ED5942FC604BAD1B12DF7683B25C6702BD8CF1BE2F5A4FFC97C82E42FD91E49A6EFF379F5F022F36E5395D64FC9430EEFCAC55F0A5";
String exponentHex = "10001";
KeyFactory factory = KeyFactory.getInstance("RSA");
BigInteger n = new BigInteger(modeHex, 16);
BigInteger e = new BigInteger(exponentHex, 16);
RSAPublicKeySpec spec = new RSAPublicKeySpec(n, e);
RSAPublicKey pub = (RSAPublicKey) factory.generatePublic(spec);
Cipher enc = Cipher.getInstance("RSA");
enc.init(Cipher.ENCRYPT_MODE, pub);
byte[] encryptedContentKey = enc.doFinal(messageg.getBytes("GB2312"));
String result = new String(Hex.encodeHex(encryptedContentKey));java加密方法如下:java加密方法如下:
Java code
String modeHex = "D548C6267CC503F1E926776A97F8644CAA67167E8FA5D74FD1F4E0BCB3608BD1583E41B102B5B4617E53B90A0C67EA652F8D96B40CFDDA6BC1501432ADCE15E4B5B916568893C94FF3CAC5ED5942FC604BAD1B12DF7683B25C6702BD8CF1BE2F5A4FFC97C82E42FD91E49A6EFF379F5F022F36E5395D64FC9430EEFCAC55F0A5";
String exponentHex = "10001";
KeyFactory factory = KeyFactory.getInstance("RSA");
BigInteger n = new BigInteger(modeHex, 16);
BigInteger e = new BigInteger(exponentHex, 16);
RSAPublicKeySpec spec = new RSAPublicKeySpec(n, e);
RSAPublicKey pub = (RSAPublicKey) factory.generatePublic(spec);
Cipher enc = Cipher.getInstance("RSA");
enc.init(Cipher.ENCRYPT_MODE, pub);
byte[] encryptedContentKey = enc.doFinal(messageg.getBytes("GB2312"));
String result = new String(Hex.encodeHex(encryptedContentKey));
Java code
String modeHex = "D548C6267CC503F1E926776A97F8644CAA67167E8FA5D74FD1F4E0BCB3608BD1583E41B102B5B4617E53B90A0C67EA652F8D96B40CFDDA6BC1501432ADCE15E4B5B916568893C94FF3CAC5ED5942FC604BAD1B12DF7683B25C6702BD8CF1BE2F5A4FFC97C82E42FD91E49A6EFF379F5F022F36E5395D64FC9430EEFCAC55F0A5";
String exponentHex = "10001";
KeyFactory factory = KeyFactory.getInstance("RSA");
BigInteger n = new BigInteger(modeHex, 16);
BigInteger e = new BigInteger(exponentHex, 16);
RSAPublicKeySpec spec = new RSAPublicKeySpec(n, e);
RSAPublicKey pub = (RSAPublicKey) factory.generatePublic(spec);
Cipher enc = Cipher.getInstance("RSA");
enc.init(Cipher.ENCRYPT_MODE, pub);
byte[] encryptedContentKey = enc.doFinal(messageg.getBytes("GB2312"));
String result = new String(Hex.encodeHex(encryptedContentKey));java加密方法如下:
Java code
String modeHex = "D548C6267CC503F1E926776A97F8644CAA67167E8FA5D74FD1F4E0BCB3608BD1583E41B102B5B4617E53B90A0C67EA652F8D96B40CFDDA6BC1501432ADCE15E4B5B916568893C94FF3CAC5ED5942FC604BAD1B12DF7683B25C6702BD8CF1BE2F5A4FFC97C82E42FD91E49A6EFF379F5F022F36E5395D64FC9430EEFCAC55F0A5";
String exponentHex = "10001";
KeyFactory factory = KeyFactory.getInstance("RSA");
BigInteger n = new BigInteger(modeHex, 16);
BigInteger e = new BigInteger(exponentHex, 16);
RSAPublicKeySpec spec = new RSAPublicKeySpec(n, e);
RSAPublicKey pub = (RSAPublicKey) factory.generatePublic(spec);
Cipher enc = Cipher.getInstance("RSA");
enc.init(Cipher.ENCRYPT_MODE, pub);
byte[] encryptedContentKey = enc.doFinal(messageg.getBytes("GB2312"));
String result = new String(Hex.encodeHex(encryptedContentKey));java加密方法如下:
Java code
String modeHex = "D548C6267CC503F1E926776A97F8644CAA67167E8FA5D74FD1F4E0BCB3608BD1583E41B102B5B4617E53B90A0C67EA652F8D96B40CFDDA6BC1501432ADCE15E4B5B916568893C94FF3CAC5ED5942FC604BAD1B12DF7683B25C6702BD8CF1BE2F5A4FFC97C82E42FD91E49A6EFF379F5F022F36E5395D64FC9430EEFCAC55F0A5";
String exponentHex = "10001";
KeyFactory factory = KeyFactory.getInstance("RSA");
BigInteger n = new BigInteger(modeHex, 16);
BigInteger e = new BigInteger(exponentHex, 16);
RSAPublicKeySpec spec = new RSAPublicKeySpec(n, e);
RSAPublicKey pub = (RSAPublicKey) factory.generatePublic(spec);
Cipher enc = Cipher.getInstance("RSA");
enc.init(Cipher.ENCRYPT_MODE, pub);
byte[] encryptedContentKey = enc.doFinal(messageg.getBytes("GB2312"));
String result = new String(Hex.encodeHex(encryptedContentKey));
2019-07-17 22:56:45