다음 코드는 Blowfish 암호화로 문자열을 암호화하는 데 적합합니다.Java에서 BlowFish로 암호화
// create a key generator based upon the Blowfish cipher
KeyGenerator keygenerator = KeyGenerator.getInstance("Blowfish");
// create a key
SecretKey secretkey = keygenerator.generateKey();
// create a cipher based upon Blowfish
Cipher cipher = Cipher.getInstance("Blowfish");
// initialise cipher to with secret key
cipher.init(Cipher.ENCRYPT_MODE, secretkey);
// get the text to encrypt
String inputText = "MyTextToEncrypt";
// encrypt message
byte[] encrypted = cipher.doFinal(inputText.getBytes());
내 비밀 키를 정의하려면 어떻게해야합니까?
덕분에 빠른 답변을 많이! – StefanE
@ 에릭도 내 질문에 봐 http://stackoverflow.com/questions/38007478/encrypt-and-decrypt-string-using-chacha20 – Nepster
이 솔루션은 직접 암호화 키로 문자열을 사용하기 때문에 안전하지 않습니다. – Robert