首页 > 解决方案 > org.springframework doesn't contain CIpher

问题描述

I want to import cipher from org.springframework dependency. I have imported it like below,

import org.springframework.security.crypto.keygen.KeyGenerators;
import org.springframework.security.crypto.encrypt.CipherUtils.Cipher;
import org.springframework.security.crypto.encrypt.SecretKey;

but there's an error throwing saying that,

Error:(25,63) java: package org.springframework.security.crypto.encrypt.CipherUtils does not exist

Then I tried

import org.springframework.security.crypto.keygen.KeyGenerators;
import org.springframework.security.crypto.encrypt.Cipher;
import org.springframework.security.crypto.encrypt.SecretKey;

I still get the below error,

Error:(25,51) java: cannot find symbol

I want cipher to use encryption and decryption of my otp and expiry date. How can I import cipher from org.springframework

标签: javaspring-bootencryptionspring-framework-beanskey-generator

解决方案


org.springframework.security.crypto.encrypt.CipherUtils不包含内部类Cipher,包org.springframework.security.crypto.encrypt也不包含类Cipher

org.springframework.security.crypto.encrypt.CipherUtils 使用javax.crypto.Cipher类,你也必须使用这个类。


推荐阅读