Padding is invalid and cannot be removed even with the same paramaters

Uncategorized
Question: I have been searching for hours and cannot find a fix that works. I have my encryption setup as so:public String EncryptData(Byte[] data, String password) { RijndaelManaged aes = new RijndaelManaged(); aes.Mode = CipherMode.CBC; aes.BlockSize = 128; aes.KeySize = 256; aes.Padding = PaddingMode.PKCS7; aes.Key = Encoding.UTF8.GetBytes(password); aes.IV = Encoding.UTF8.GetBytes(password.Substring(0, 16)); ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV); using (MemoryStream ms = new MemoryStream()) { using (CryptoStream writer = new CryptoStream(ms, encryptor, CryptoStreamMode.Write)) { writer.Write(data, 0, data.Length); writer.FlushFinalBlock(); Byte[] msBytes = ms.ToArray(); String b64encrypted = Convert.ToBase64String(msBytes); return b64encrypted; } } } My decryption method:private String decryptData(String password, String data) { RijndaelManaged aes = new RijndaelManaged(); aes.Mode = CipherMode.CBC; aes.BlockSize = 128; aes.KeySize = 256; aes.Padding = PaddingMode.PKCS7; aes.Key = Encoding.UTF8.GetBytes(password); aes.IV = Encoding.UTF8.GetBytes(password.Substring(0, 16)); ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV); using (MemoryStream ms…
Read More

Iterating through array in Rails as separate jQuery objects

Uncategorized
Question: I am iterating through an array in Rails to show a set of articles. I'd like a button to slide Toggle the article open when clicked (so each would be a headline and button, and the text would be revealed on button click). The array looks like: Show More! I am then trying to toggle the article_content with the following: After reading some other questions, I believe the issue is that article_content is a class, which is why currently the button opens and collapses all of the content text. If I am iterating through an array, can I assign different IDs to target as my object so clicking the button for Article 1 opens and closes Article 1 only? Answer: Unless you have a specific reason to assign the…
Read More

Java POST request to get token from web service

Uncategorized
Question: I need to get access from java application to some RESTful web service which uses token-based authentication. As I understood the best choice for this purpose is to use JAX-RS-based libraries like Jersey, but I am very new to this matter. Maybe someone could help me by giving example code of proper request to get a token from web service. What we have:URI of the token issuing server. It uses oAuth2 authorization. clientId and clientSecret. We have to submit them to the token issuing server which will verify them and return a token. URI of the web service itself. username and password for service access. As I understood, to get a token I have to send POST request along with the following headers:"Authorization", "Basic YWRhMGI3NTicdscsN2I0MjNjM2EwNWQ0MjM2ZTg6QU1hS0ltUEZJaUFSR3dGMmJ3NjZZVi9Ec05YZTd0ZkEerfrvegezNoND0=" ("Basic " + base64…
Read More