aes

AES-256/CBC encryption with OpenSSL and decryption in C#

让人想犯罪 __ 提交于 2019-11-29 15:00:34
I am a newbie to cryptography. My requirement is to decrypt/encrypt the text that is encrypted/decrypted using openssl. The algorithm that we are using is aes-256-cbc in the Openssl. So, I am trying to implement the same functionality in my application. so far after a lot of googling all i was able to do is.. private static string Encryptor(string TextToEncrypt) { //Turn the plaintext into a byte array. byte[] PlainTextBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(TextToEncrypt); //Setup the AES providor for our purposes. AesCryptoServiceProvider aesProvider = new AesCryptoServiceProvider()

Unable to replicate an encryption format from Java to PHP

独自空忆成欢 提交于 2019-11-29 14:56:00
I have the following Java code which was shared by one of an integration partner for their API encryption import java.nio.ByteBuffer; import java.security.AlgorithmParameters; import java.security.SecureRandom; import java.security.spec.KeySpec; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.SecretKeySpec; import org.apache.commons.codec.binary.Base64;

Null character in encrypted data

懵懂的女人 提交于 2019-11-29 14:55:13
Is it possible that after cbc encryption, null character appears in the resulting multibyte data. If yes, what precaution should I take to avoid it. Is it possible that after cbc encryption, null character appears in the resulting multibyte data. Absolutely. It would not be a pseudo-random function if values like 0's were missing. If yes, what precaution should I take to avoid it. Treat everything as a byte array with embedded NULL s. Never treat it like a char* . If you want to treat it like a char* , then you will need to encode it first. Try hexadecimal, Base32 or Base64. 来源: https:/

Java to JS and JS to Java encryption using cryptojs

纵然是瞬间 提交于 2019-11-29 14:37:34
问题 I got on this post a couple of weeks ago and worked perfectly: Compatible AES algorithm for Java and Javascript Now, I need to do the reverse operation, but once in java, I am getting this exception: javax.crypto.BadPaddingException: Given final block not properly padded at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:966) at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:824) at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:436) at javax.crypto

Can I exploit GPU to do AES encryption from .NET? If so, how?

浪尽此生 提交于 2019-11-29 14:22:03
问题 Interesting paper from Trinity College of Dublin: AES Encryption Implementation and Analysis on Commodity Graphics Processing Units Their technique uses openGL to enlist the GPU to do the numeric transforms required by AES. How difficult would it be to expose this capability - performing stream encryption - via a managed .NET library? How would I get started? Hints? Examples? EDIT : Anyone have experiences to relate using CUDA or Accelerator? 回答1: You could use Microsoft's Accelerator library

AES, Serpent or Twofish in C example?

╄→гoц情女王★ 提交于 2019-11-29 13:56:55
问题 I found a lot of implementations of AES, Twofish and Serpent in C. But I don't really understand the examples. I only understand that some where provided with examples to invert a matrix. Can someone point me to an example or .c file for to encrypt/decrypt data represented by a char* and a password? 回答1: The wikipedia article actually links to an excellent tutorial (by X-N20) written in C that walks you through the Maths and provides C implementations on the go, which is quite useful for

Different results in AES256 encryption in Swift (iOS) and PHP

廉价感情. 提交于 2019-11-29 13:52:40
问题 I am working in AES256 to be able to encrypt/decrypt between iOS and PHP using insecure channels. I have seen many similar questions that move around the key size, the mode (CBC or ECB), the use of a random iv, etc. But in this case, I found a weird behaviour as follows. Configuration in both environments: - Key: 32 bytes(256 bits) - Block size: 128 bits (standard) - iv: 16 bytes (static for testing purposes) - Mode: CBC If I encrypt a 16 or 32 bytes text (to match the AES block size), the

Different encryption results using C# and CryptoJS

人走茶凉 提交于 2019-11-29 12:58:20
I encrypt some data using AES in a server application, which is written in C#. I use a predefined key (32 bytes) and IV (16 bytes), for instance... Key: 81fe1681..6a451c1c IV: e83c..ae76 This is my C# code I use to encrypt the data: async Task<byte[]> Encrypt(string privateKey, string pin, byte[] data) { using (var sha = SHA256.Create()) { byte[] keyHash = sha.ComputeHash(Encoding.UTF8.GetBytes($"{privateKey}")); byte[] pinHash = sha.ComputeHash(Encoding.UTF8.GetBytes($"{pin}")); using (Aes aes = Aes.Create()) { byte[] key = keyHash.Slice(0, aes.Key.Length); byte[] iv = pinHash.Slice(0, aes.IV

iOS9 - NSAppTransportSecurity

久未见 提交于 2019-11-29 12:33:27
iOS9 - NSAppTransportSecurity 配置要求 属性结构 属性详解 事例讲解 只有HTTPS 所有网址都不经过ATS关闭ATS 所有网址都经过ATS添加一些例外白名单 所有网址都不经过ATS添加例外 使用低等级版本的TLS协议 如何配置 iOS9 - NSAppTransportSecurity 原文地址: http://www.pluto-y.com/ios9-nsapptransportsecurity/ App Transport Security(以下均称 ATS )是iOS9提供的一个新特性,主要是保证app和web服务之间的安全。如果不想开启的话,可以关闭这个特性。 所有用到 NSURLConnection 、 CFURL 以及 NSURLSession API都会触发 ATS (使用iOS9的SDK编译)验证, 所以在iOS9中需要符合一些配置才可以使 ATS 正常运行。 配置要求 关于App Transport Security 的一些进本配置要求: * 服务器只要支持TLS协议1.2 * 加密算法也是有限制,需要在以下列表中 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256

How to handle “last block incomplete in decryption”

心已入冬 提交于 2019-11-29 12:20:09
问题 I have a simple class to try and wrap encryption for use elsewhere in my program. import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.spec.SecretKeySpec; public final class StupidSimpleEncrypter { public static String encrypt(String key, String plaintext) { byte[] keyBytes = key.getBytes(); byte[] plaintextBytes = plaintext.getBytes(); byte[] ciphertextBytes = encrypt(keyBytes, plaintextBytes); return new String(ciphertextBytes)