cryptojs

Javascript AES encryption doesn't match iOS AES encryption

烈酒焚心 提交于 2020-01-16 04:24:32
问题 I am encrypting an NSString in iOS like this which encodes and decodes fine: NSString *stringtoEncrypt = @"This string is to be encrypted"; NSString *key = @"12345678901234567890123456789012"; // Encode NSData *plain = [stringtoEncrypt dataUsingEncoding:NSUTF8StringEncoding]; NSData *cipher = [plain AES256EncryptWithKey:key]; NSString *cipherBase64 = [cipher base64EncodedString]; NSLog(@"ciphered base64: %@", cipherBase64); // Decode NSData *decipheredData = [cipherBase64 base64DecodedData];

CryptoJS no method mixIn

假装没事ソ 提交于 2020-01-16 04:03:05
问题 I am getting the following error in my browser (Chrome): Uncaught TypeError: Object [object global] has no method 'mixIn' aes.js:28 d.CipherParams.l.extend.init aes.js:28 c.hasOwnProperty.c.init sha1.js:7 e jQuery.js:7 Wc jQuery.js:7 Wc jQuery.js:7 n.param jQuery.js:7 n.extend.ajax jQuery.js:7 saveCurrentNote (index):88 selectNote (index):97 (anonymous function) (index):125 n.event.dispatch jQuery.js:6 r.handle Here is the source code: <script type="text/javascript" src="<?php echo Yii::app()

OpenSSL and CryptoJS SHA256 encryption conversion

血红的双手。 提交于 2020-01-14 19:36:07
问题 My problem is that the newer versions of OpenSSL aren't compatible with default settings of CryptoJS. The default hash used by openssl enc for password-based key derivation changed in 1.1.0 to SHA256 versus MD5 in lower versions. https://unix.stackexchange.com/questions/344150/why-can-one-box-decrypt-a-file-with-openssl-but-another-one-cant/344586#344586 By default, CryptoJS uses MD5 for its key derivation. OpenSSL used MD5, but now in OpenSSL versions >=1.1.0 it's using SHA256. So if I pass

C# SHA256 ComputeHash result different with CryptoJS SHA256 function

浪尽此生 提交于 2020-01-12 22:22:53
问题 I have a C# function as below: string stringvalue = "530500480530490480530480480520570480520510500490"; var encodedvalue= Encoding.Unicode.GetBytes(stringvalue); using (HashAlgorithm ssp = System.Security.Cryptography.HashAlgorithm.Create("SHA256")) { var digest = ssp.ComputeHash(encodedvalue); return BitConverter.ToString(digest); } I need to create a javascript function that match the code above so that the end result for both C# and JS is the same. Currently in my JS code, I'm using this:

How does CryptoJS get an IV when none is specified?

扶醉桌前 提交于 2020-01-11 02:41:10
问题 When using CryptoJS.AES.encrypt how does it come up with an Initialization Vector if the third argument is not passed to the function? Is there a way to get it out of the encrypted string? The reason I need this is I need to decrypt something CryptoJS.AES.encrypt returned using Lua, but I only have the key that was provided. 回答1: CryptoJS' CryptoJS.<BlockCipher>.encrypt has two modes of encryption. If you pass in a key that is not a string , but rather a WordArray (CryptoJS's internal

Translation from Python to JavaScript: HMAC-SHA256

▼魔方 西西 提交于 2020-01-04 07:09:08
问题 I'd like to convert the following piece of Python code to JavaScript: signature_string = self.format("{apip_id}{identity_id}{method}{uri}{content_hash}{timestamp}{nonce}") # pyhton unicode string in UTF-8 format signature_bytes = signature_string.encode('utf-8') # previous string is converted in a python bytes string apip_key_bytes = base64.b64decode(self.apip_key.encode('utf-8')) # pyhton unicode string is converted in a python bytes string and then in ?? hasher = hmac.new(apip_key_bytes,

AES decryption with password using CryptoJS returns a blank value

馋奶兔 提交于 2020-01-03 08:38:29
问题 Scenario I've got the following code: <script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script> <div id="decrypted">Please wait...</div> Insert new note:<input type="text" id="new_note"><input type="button" id="enc_button" value="Save"> <script> var password = "testpassword"; var encrypted_text = localStorage.getItem("encrypted"); var rawData = atob(encrypted_text); var iv = rawData.substring(0,16); var crypttext = rawData.substring(16); var plaintextArray =

AES decryption with password using CryptoJS returns a blank value

社会主义新天地 提交于 2020-01-03 08:38:05
问题 Scenario I've got the following code: <script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script> <div id="decrypted">Please wait...</div> Insert new note:<input type="text" id="new_note"><input type="button" id="enc_button" value="Save"> <script> var password = "testpassword"; var encrypted_text = localStorage.getItem("encrypted"); var rawData = atob(encrypted_text); var iv = rawData.substring(0,16); var crypttext = rawData.substring(16); var plaintextArray =

CryptoJS encrypts AES with passphrase but PHP decrypt needs a key

别说谁变了你拦得住时间么 提交于 2020-01-02 04:30:32
问题 I am using CryptoJS to encrypt a string: function doHash(msg){ msg = String(msg); var passphrase = 'aggourakia'; var hash = CryptoJS.AES.encrypt(msg, passphrase); var ciphertext= hash.ciphertext.toString(); //return ciphertext instead of object return ciphertext; } As I understand it, CryptoJS uses the passphrase to generate a key , which is then used to encrypt the data. However I'd like to decrypt the cipher using a PHP function, or maybe an online tool such as this: http://aesencryption

Encrypt in javascript and decrypt in C# with AES algorithm

我们两清 提交于 2020-01-01 18:53:06
问题 I tried to encrypt in angular using AES librery from AES. I encrypt string using the CryptoJS.AES.encrypt() method from AES. here my code: var txtloginKod = 'Some String...'; var key = CryptoJS.enc.Utf8.parse('8080808080808080'); var iv = CryptoJS.enc.Utf8.parse('8080808080808080'); var encryptedlogin = CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(txtloginKod), key, { keySize: 128 / 8, iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }); The method CryptoJS.AES.encrypt() return a