(String[] args)
| 148 | } |
| 149 | |
| 150 | public static void main(String[] args) throws IOException { |
| 151 | String plainText = "I Love You Every Day"; |
| 152 | String s = Util.byteToHex(plainText.getBytes()); |
| 153 | System.out.println("原文" + s); |
| 154 | SM4Utils sm4 = new SM4Utils(); |
| 155 | //sm4.secretKey = "JeF8U9wHFOMfs2Y8"; |
| 156 | sm4.secretKey = "1d8c95e41c72969c66b88c4911d376ca"; |
| 157 | sm4.iv = "97f4db469af2df1595f4c81664666883"; |
| 158 | sm4.hexString = true; |
| 159 | |
| 160 | System.out.println("ECB模式加密"); |
| 161 | String cipherText = sm4.encryptData_CBC(plainText); |
| 162 | System.out.println("密文: " + cipherText); |
| 163 | System.out.println(""); |
| 164 | |
| 165 | String plainText2 = sm4.decryptData_ECB("9a2eb12038cf8e85873c63fb45d2a0424e8a2ac8d2ed0a84271a9a5ee63a8e07ab11015e14e1741d51bde64c00240e16f126b322575cb68999de33d4daf6a8c36b0d25f9dc074a560d95b562d5b9fc640c0d8fe4f0461f1663fb01c76effee06040000436413590dc7677dd13f98f3d45115c817852292a0ed9716bd6d286358eb908b46c41a96e7f261a2e5bfb34bf71dfa4773d84be350628773c4dc2e82eacb1cdcb1f3e216ec3a2ec8544b78010febeb99697afc37f8352c9099490d8e13"); |
| 166 | System.out.println("明文: " + plainText2); |
| 167 | |
| 168 | // System.out.println("CBC模式加密"); |
| 169 | // sm4.iv = "31313131313131313131313131313131"; |
| 170 | // String cipherText2 = sm4.encryptData_CBC(plainText); |
| 171 | // System.out.println("加密密文: " + cipherText2); |
| 172 | // System.out.println(""); |
| 173 | // |
| 174 | // String plainText3 = sm4.decryptData_CBC(cipherText2); |
| 175 | // System.out.println("解密明文: " + plainText3); |
| 176 | |
| 177 | } |
| 178 | } |
nothing calls this directly
no test coverage detected