aes

前端加密传输 crypto-js AES 加密和解密

匿名 (未验证) 提交于 2019-12-02 20:32:16
配置: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <title>Document</title> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.js"></script> <script> function getAesString(data, key, iv) { //加密 var key = CryptoJS.enc.Utf8.parse(key); var iv = CryptoJS.enc.Utf8.parse(iv); var encrypted = CryptoJS.AES.encrypt(data, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }); return encrypted.toString()

Is there any difference, if I init AES cipher, with and without IvParameterSpec

偶尔善良 提交于 2019-12-02 19:36:49
I was wondering, is there any difference, if I init AES cipher, with and without IvParameterSpec? With IvParameterSpec SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec(new byte[16])); Without IvParameterSpec SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec); I tested with some sample test data, their encryption and decryption result yield the same. However,

Is the file Encrypted with AES? [closed]

我只是一个虾纸丫 提交于 2019-12-02 19:24:32
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Is there a way to tell if a file has been encrypted already if I know the Algorithm was AES? I would have been the one to encrypt it, so information to decrypt or encrypt is not a problem. However, if you try to decrypt a file that has not been encrypted you'll lose all the data. If you encrypt it twice, you get

AES encryptor not working

和自甴很熟 提交于 2019-12-02 19:17:52
问题 I am attempting to get this AES sample code working. However I am not getting anything returned to my cipherText variable. I am not getting errors, just nothing returned. What am I doing wrong here? public byte[] key { get; set; } public byte[] IV { get; set; } public byte[] ciphertext { get; set; } public string plainText { get; set; } public byte[] Encrypt(string InputPlaintext) { InputPlaintext = "attack at dawn"; using (AesCryptoServiceProvider AESEncryptor = new AesCryptoServiceProvider(

JAVA AES 256 & Public Key Encryption [closed]

人走茶凉 提交于 2019-12-02 19:06:46
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . One of our customers requires us to encrypt a message return from our web service using AES 256 & Public Key Encryption Server Side (web service) is java based. Client side could be java or .Net. I'm not familiar

What causes the error “java.security.InvalidKeyException: Parameters missing”? [duplicate]

瘦欲@ 提交于 2019-12-02 18:41:26
This question already has an answer here: Why does my AES encryption throws an InvalidKeyException? 1 answer I'm trying to encrypt and decrypt a string using AES but getting an error I don't know how to resolve. This is the code: public class EncryptionTest{ public static void main(String[] args) { String encrypt = new String(encrypt("1234567890123456")); System.out.println("decrypted value:" + (decrypt("ThisIsASecretKey",encrypt))); } public static String encrypt(String value) { try { byte[] raw = new byte[]{'T', 'h', 'i', 's', 'I', 's', 'A', 'S', 'e', 'c', 'r', 'e', 't', 'K', 'e', 'y'};

aes 128 message decryption — Swift, iOS

℡╲_俬逩灬. 提交于 2019-12-02 18:19:09
问题 I'm trying to decrypt message with 128 key with following code. This is an extension for String: func aesDecrypt(key:String, iv:String, options:Int = kCCOptionPKCS7Padding) -> String? { if let keyData = key.dataUsingEncoding(NSUTF8StringEncoding), data = NSData(base64EncodedString: self, options: .IgnoreUnknownCharacters), cryptData = NSMutableData(length: Int((data.length)) + kCCBlockSizeAES128) { let keyLength = size_t(kCCKeySizeAES128) let operation: CCOperation = UInt32(kCCDecrypt) let

Different output encryption both CryptoJS and Java Code

我只是一个虾纸丫 提交于 2019-12-02 18:16:33
I need to encrypt certainly string from client-side (JavaScript) and decrypt from server-side (Java), so I found CryptoJS and I write the code with the same params/configuration of mi Java Code but the output is always different, do you have any idea or what happen? I'm use CBC with NoPadding CryptoJS http://jsfiddle.net/Soldier/gCHAG/ <script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"> </script> <script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/pad-nopadding-min.js"></script> <script> function padString(source) { var paddingChar = ' ';

AES encryption using Java and decryption using Javascript

浪尽此生 提交于 2019-12-02 17:46:22
I am making an application which needs Java based AES Encryption and JavaScript based decryption. I am using the following code for encryption as a basic form. public class AESencrp { private static final String ALGO = "AES"; private static final byte[] keyValue = new byte[] { 'A', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k','l', 'm', 'n', 'o', 'p'}; public static String encrypt(String Data) throws Exception { Key key = generateKey(); Cipher c = Cipher.getInstance(ALGO); c.init(Cipher.ENCRYPT_MODE, key); byte[] encVal = c.doFinal(Data.getBytes()); String encryptedValue = new BASE64Encoder

AES256 CBC + HMAC SHA256 ensuring confidentiality *and* authentication?

梦想与她 提交于 2019-12-02 17:42:24
I'm thinking of using AES256 CBC + HMAC SHA-256 as a building block for messages that ensures both confidentiality and authentication. In particular, consider this scenario: Alice is possession a public key belonging to Bob (the key exchange and algorithm is outside the scope of this question). Alice has an identifying key K, also shared with Bob, that she can use to identify herself with. Only Alice and Bob knows the key K. Alice encrypts (nonce || K) using Bob's public key. Bob decrypts the packet and has now has K and nonce. Bob uses SHA-256 with SHA256(K || nonce) to yield a K(e) of 256