本文共 439 字,大约阅读时间需要 1 分钟。
AesCipherService aesCipherService = new AesCipherService(); aesCipherService.setKeySize(128); //设置key长度 //生成key Key key = aesCipherService.generateNewKey(); String text = "hello"; //加密 String encrptText = aesCipherService.encrypt(text.getBytes(), key.getEncoded()).toHex(); //解密 String text2 = new String(aesCipherService.decrypt(Hex.decode(encrptText), key.getEncoded()).getBytes()); Assert.assertEquals(text, text2);
参考自()
转载地址:http://zmazi.baihongyu.com/