I was able to successfully encrypt a message with a generated key. Now I am trying to achive decryption whereby a user would enter a key (hex) and there encrypted message (hex). I am having a problem when decrypting the the encrypted message (hex). I receive multiple NullPointerExceptions. Could you possible help me figure out a solution to this problem please?  //Edit: For Example the key (Hex): CFDD0F5311764F9EA56CF4126E304BC2 | Encrypted Message: C2A80A2B7A84A5A785E059F19322E5BA  private void executeDecryption() {     encryptMessageStr = messageEncryptTA.getText();     algorithmType = decryptAlgorithmTypeCB.getSelectionModel().getSelectedItem();     keyDecrypt = keyTF.getText();      if (!messageEncryptedTA.getText().isEmpty()) {          try {             //Using decryptText()             String textDecipher = decryptText(encryptedMessageStr, keyDecrypt);             messageEncryptedTA.setText(textDecipher);          } catch (Exception ex) {             MessageBox.display("Error!", "Could not decrypt message! Please try again later");             //System.out.println(ex.getMessage());         }      } else {         MessageBox.display("Warning!", "Please make sure message field is not empty!");     } }  public static String decryptText(String encryptedMessageStr, String secretKey) {     try {         Key k = new SecretKeySpec(Base64.getDecoder().decode(secretKey), "AES");         Cipher cipherAES = Cipher.getInstance("AES");         cipherAES.init(Cipher.DECRYPT_MODE, k);          byte[] decodedValue = Base64.getDecoder().decode(encryptedMessageStr);         byte[] cipherTextBytes = cipherAES.doFinal(decodedValue);         String decryptedValue = new String(cipherTextBytes);         return decryptedValue;      } catch (Exception ex) {         ex.printStackTrace();     }      return "Error";  }   Edited:   EXCEPTION: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher
129
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
89879
I am looking at the different attacks on RSA. I came across known-plaintext attack where the public key can be used to encrypt all possible messages until it finds a match on the sent encrypted message. However, on the book I found in the library it seems this form of attack is also called "Forward search attack".      If the message space is small or predictable, an adversary can decrypt a ciphertext c by simply encrypting all possible plaintext messages until c is obtained. Salting the message as described above is one simple method of preventing such an attack. -Handbook of Applied Cryptography   So are these attacks the same with different names or have I misunderstood it?
2136
I am looking for a way to convert a long string (from a dump), that represents hex values into a byte array.  I couldn't have phrased it better than the person that posted .  But to keep it original, I'll phrase it my own way: suppose I have a string "00A0BF" that I would like interpreted as the  byte[] {0x00,0xA0,0xBf}   what should I do?  I am a Java novice and ended up using BigInteger and watching out for leading hex zeros. But I think it is ugly and I am sure I am missing something simple.
84512
If I have the plain text, the ciphertext and the key for an AES-128 CBC operation, can I determine the IV, even if I don't know the padding (assuming the padding follows one of the more common formats)?  I believe it should be possible since my understanding is that the IV is only used as an initial XOR of the plain text in encryption, and should, therefore, be able to be available like this:  AESDecrypt(key, ciphertext) =&gt; (PlainText XOR IV); IV = ((Plaintext XOR IV) XOR (Plaintext))   Is this correct?
60076
I am looking to encrypt some data using  in  using a specific key and  value. Are there any good function libraries or COM components that would be good to use?  I looked at ; it allows a passphrase only, and won't allow setting specific key and IV values.
7578
How can I encrypt and decrypt a string in C#?
60150
I'm working with some example java code for making md5 hashes. One part converts the results from bytes to a string of hex digits:  byte messageDigest[] = algorithm.digest();      StringBuffer hexString = new StringBuffer(); for (int i=0;i&lt;messageDigest.length;i++) {     hexString.append(Integer.toHexString(0xFF &amp; messageDigest[i]));     }   However, it doesn't quite work since toHexString apparently drops off leading zeros. So, what's the simplest way to go from byte array to hex string that maintains the leading zeros?
111228
Am I missing something, or is RSA very very limiting when it comes to ecrypting data when it comes to the actual message size?  I have read that you can only encrypt a message of around 117 to 200 bytes in size (depending on your key size: 1024 or 2048 bits). Is this correct?  If so, I think I have read people suggesting on using it for larger files. I guess they are just repeating the process many times over and over in blocks of 117 bytes?
19576
Let's say that there is a binary file encrypted with AES in CBC mode (i.e. using a key and initialization vector). If key is known, but IV is not, is it easy to fully decrypt the file?  How hard is it?
44654
We want to encrypt / encode URL parameters on our pages. I tried to encrypt a parameter using  with AES algorithm as explained in the   %%[SET @encData=EncryptSymmetric("test", "AES", @null, "1111", @null, "0000000000000000", @null, "00000000000000000000000000000000") ]%% AES: %%=v(@encData)=%%   The result of this function is      AT1r0irnzM+Ax1j8zN+zAw==   Then I tried to decrypt the value using an , but I always received an error message.  I suppose there is a difference between AES algorithm in Marketing Cloud and AES used in the online tool. Indeed if I encrypt the same word with an online tool (128-bit), I received this result      l4Yo3sFofFD1EMmtoh397w==   Do you have any deep information regarding this function? What could be the difference?
45755
What if, instead of using CBC mode in the normal way with a random IV, I used this approach:   Use a fixed IV (like a block of 0's). Before encrypting, generate a random block and prepend it to the plaintext. After decrypting, ignore the first block.   Is this exactly the same in terms of security as using a random IV?  Also, would it make any difference if I used something like a message counter instead of a random block in step 2?
82522
Suppose there is a message that is encrypted with AES-128-CBC.  The message is as follows, new lines are used to delimit the 16 byte boundary for each block:  Wire funds from: Alice to Bob in   the amount of $ 1   Because this message is encrypted using CBC mode,  any modification of the first block of cipher text would propagate throughout the message.   However, the amount of the fund transfer falls in the last block.  I am under the assumption that an attacker can use the property of  to alter the last block and produce a valid amount that is greater than \$1 in far fewer than $2^{128}$ operations.   Is this a correct assumption?  Is there a name for this attack or do you know of a real world example?    My instinct is that if you just need one byte of the 16 byte block to be of a specific value then it would only require $2^8$ operations because the other 120 bits of the plain text could be any value. For example lets say we wanted the last block of cipher text to decrypt to 9\0 (where \0 denotes a single null byte, and the message would be interpreted as \$9), then it would take only $2^{16}$ operations to find this cipher text block.  Is there something I am missing?
33556
At least it's my understanding that AES isn't affected by known-plaintext. Is it immune to such an attack, or just resistant? Does this vary for chosen-plaintext?
90748
Let's imagine a cipher that works like the following:   Plaintext is encoded to Base64. The characters in the encoded plaintext are substituted with a randomly shuffled character set(A-z, 0-9, -, _, =).  The shuffled alphabet is, in essence, the key.   Not particularly complex or even secure.  But...  What if I wanted to do frequency analysis?  For example, "RUNFORYOURLIFE" when encoded in Base64 is:  UlVORk9SWU9VUkxJRkU=  When the character set is shuffled, the final cryptext can look something like this:  xv24DYG9qxG2xYg6DYxf  The key being:   yhAc5bTOWeYvBXCpVuoMJLdg8P1jHN3ZIsi67SrK4E_D9-x2qRQmnlkwUaFt0G=zf  Which is a shuffled version of:  abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_=  Let's also assume that the character set in subsequent messages is in the same order(ie the key is re-used).  Since the bytes are basically split up resulting in different character units that may or may not correspond, is frequency analysis still feasible?  Does encoding plaintext this way before encryption add any form of security?  My question mostly pertains to longer messages, as my example may be too short for any sort of real analysis.
9851
I have three messages, each known to be XOR-encoded, with the same key used for each message of this XOR cipher.  Encoded message 1: $e_1\,=\,00100111010$ Encoded message 2: $e_2\,=\,01001110110$ Encoded message 3: $e_3\,=\,11010110101$  I also have an extra information: I know that the decoded contents of $e_1\oplus e_2$ is equal to the decoded contents of $e_3$. How would one go about solving this problem, in order to get the key and decode the contents of the message?
93462
I know that rsa normally is made to make it with big integers, but i trying to make the algorithm myself (with the help of wikipedia) and I´m making it with small numbers to track the problems easily.  The problem is that sometimes the decryption of the crypted message is wrong! Exactly when I choose p=11 and q=5, the rest goes like this:  n=55 euler(n)=40 = (p-1)(q-1) e=13 d=37   the crypted message (using message=65) is:  c=10   and using the chinese reminder theorem (wikipedia´s advise):  Dp=7 Dq=1 Qinv=9 m1=10 m2=0 h=2   and the decrypted message is:  message=10 !!!!!   It´s a problem of the choosen prime numbers? I think that the rest I made it fine, I also check it with rsa calculator:   I know also that to choose d and e there are more options, but the choosen ones they would be fine too. Maybe there is some other condition that is not in the wikipedia?
14562
I found a program which takes a purely alphabetical message, converts the letters to their ASCII values and combines them with the ASCII values of an alphabetical key (wrapping around when it gets to Z).  (The key being used is fully random and is required to be at least a long as the message.)  But from what I usually read about one-time pads, the message and the key are in binary, and the bits in the message is XORed with the key to produce the ciphertext. Combining the ASCII values sounds like a similar but obviously very different process.  Is this a valid way to implement a one-time pad? Or does the process merely resemble the binary XOR and doesn't have the same cryptographic properties as a one-time pad?