Комментарии:
How can I encrypt and decrypt the same text but always return the same result for the same text?
Ex:
1° cryptography
input = "Test"
encrypt(input) = 123456Abc
decrypt(123456Abc) = "Test"
2° cryptography
input = "Test"
encrypt(input) = 123456Abc (same input [Test] returned the same result)
decrypt(123456Abc) = "Test"
How do we come to know our output is correct?
What is key value?
Thanks man great video, only critique is the font size
ОтветитьDoes this work still if you input a string that includes spaces or special characters ?
thank you
What if someone has access to this code? I mean if he knows the the encryption works.
ОтветитьHow do I store the key, to Decrypt later?
Ответитьimport javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.ExecutionException;
public class encrip {
private static final String UNICODE_FORMAT = "UTF-8";
public static void main(String[] args) {
String text = "Holiwis";
try {
SecretKey key = generateKey("AES"); // generamos llave
Cipher chipher;
chipher = Cipher.getInstance("AES");
byte[] encryptedData = encryptString(text, key, chipher);
String encryptedString = new String(encryptedData); // Dato encriptado
System.out.println(encryptedString);
String decrypted = decryptString(encryptedData, key, chipher);
System.out.println(decrypted);
}catch (Exception d){
}
}
public static SecretKey generateKey (String encryptionType){
try {
KeyGenerator keyGenerator = KeyGenerator.getInstance(encryptionType);
SecretKey myKey = keyGenerator.generateKey();
return myKey;
}catch (Exception r){
return null;
}
}
public static byte[] encryptString (String dataToEncrypt, SecretKey myKey , Cipher cipher){
try{
byte[] text = dataToEncrypt.getBytes(UNICODE_FORMAT);
cipher.init(Cipher.ENCRYPT_MODE, myKey);
byte[] textEncrypted = cipher.doFinal(text);
return textEncrypted;
}catch (Exception m){
return null;
}
}
public static String decryptString (byte[] dataToDecrypt, SecretKey myKey , Cipher cipher) {
try {
cipher.init(Cipher.DECRYPT_MODE, myKey);
byte[] textDecrypted = cipher.doFinal(dataToDecrypt);
String result = new String(textDecrypted);
return result;
} catch (Exception n) {
return null;
}
}
}
Tip: Please make your font bigger or zoom your video little more. Its very useful for everyone.
Great video thanks.
Hello master , im sorry to write here , I am really proud of you - You have a lot to offer people - This is a wonderful thing. I hope you continue your creativity - I have a question, how is it extracted (server seed) from (server seed hash SHA-256) -
for example this server seed (4f68926f4a05851ccf1f85f4312592ecfbd86be8135f610ec8011eb68862add9) will give me hash-256 (2168b9e8f9499d5ac6f8bdec4da9598c8fbb927b5f90a2e5972f1e01cebdff52) on site xorbin , but if i dont have (server seed) - i have only server seed hash-256 how i can Decrypt to server seed , and that using CryptoJS v3.1.2 ( Base64 ) random ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
thanks master
can is use this code for Camellia encryption?
ОтветитьPlease provide source code please.
Ответитьbro, please provide code for the same...!!! its urgent :(
ОтветитьThanks for the video. Trying to get this to work but .. how do you get encrypted data into a byte[] if you didn't encrypt it in the same session?
e.g. I want to write to a file something unreadable (encrypted). Next run, i want this to be readable (decrypted). I have to feed the decryptString method with a byte[] containing the encrypted data.
I don't see how I could get the encrypted data into byte[]. I feel like I am missing something....😬
Hey, how to do the same thing but with files? I want to encrypt some text, write it to the file and then read the file and decrypt the text. How to use the same secret key and not generate the new one each time. Thanks
ОтветитьHey man how do i make this 256 bits?
ОтветитьYou're awesome! but.. why don't you use Dark Mode?
ОтветитьHi,
How would I make a program that accepts a plaintext, letter array and encrypted arrayList and uses these parameters to encrypt the word and return it.?
you are a godsend during this quarantine. like the joe wick for programming
ОтветитьInteresting!❤👏
Ответить