ब्लॉफिश एन्क्रिप्शन के साथ स्ट्रिंग को एन्क्रिप्ट करने के लिए निम्नलिखित कोड ठीक काम करता है।जावा में ब्लोफिश के साथ एन्क्रिप्शन
// 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
@Erik भी मेरे प्रश्न पर एक नज़र डालें http://stackoverflow.com/questions/38007478/encrypt-and-decrypt-string-using-chacha20 – Nepster
यह समाधान असुरक्षित है क्योंकि यह सीधे स्ट्रिंग को क्रिप्टोग्राफिक कुंजी के रूप में उपयोग करता है। – Robert