博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Shiro 提供的AES 对称式加密/解密方式——AesCipherService的使用案例
阅读量:3959 次
发布时间:2019-05-24

本文共 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/

你可能感兴趣的文章