(String plainText)
| 26 | |
| 27 | |
| 28 | public String encryptData_ECB(String plainText) { |
| 29 | try { |
| 30 | SM4_Context ctx = new SM4_Context(); |
| 31 | ctx.isPadding = true; |
| 32 | ctx.mode = SM4.SM4_ENCRYPT; |
| 33 | |
| 34 | byte[] keyBytes; |
| 35 | if (hexString) { |
| 36 | keyBytes = Util.hexStringToBytes(secretKey); |
| 37 | } else { |
| 38 | keyBytes = Util.hexStringToBytes(secretKey); |
| 39 | } |
| 40 | |
| 41 | SM4 sm4 = new SM4(); |
| 42 | sm4.sm4_setkey_enc(ctx, keyBytes); |
| 43 | byte[] encrypted = sm4.sm4_crypt_ecb(ctx, plainText.getBytes("UTF-8")); |
| 44 | System.out.println("SM4Utils 44 " + Util.byteToHex(encrypted)); |
| 45 | return Util.byteToHex(encrypted); |
| 46 | } catch (Exception e) { |
| 47 | e.printStackTrace(); |
| 48 | return null; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | public String decryptData_ECB(String cipherText) { |
| 53 | try { |
no test coverage detected