cryptojs

How to decrypt an ArrayBuffer?

笑着哭i 提交于 2019-11-30 02:25:55
I've been trying to decrypt an ArrayBuffer object using CryptoJS, but so far it always returns a blank WordArray. The files (images) are encrypted in an iOS and Android app, sent to a server, and downloaded in this web app to be decrypted and displayed. The iOS and Android apps are able to decrypt the files without problems, so there's nothing wrong with the encryption process. The files are downloaded with an XMLHttpRequest with responseType set to arraybuffer . Here's my code so far: // Decrypt a Base64 encrypted string (this works perfectly) String.prototype.aesDecrypt = function(key) { var

Decode a Base64 String using CryptoJS

最后都变了- 提交于 2019-11-30 00:49:15
I am trying to create a simple webpage with the goal to send and encrypted message to the server (which will create a file with that content), then a link is created and the user who receive the link provided will be able to see the encrypted value (since it provides the name of the file and the key). The message is encrypted using CryptoJS AES, and the result is Base64 encoded to be decoded after that, only the Base64 of the encrypted message and the encrypted message is sent to the server nothing else, and this is done using Javascript. My question here is. I have a message, let say "Hello

Can't decrypt string with CryptoJS

无人久伴 提交于 2019-11-29 18:04:33
问题 I'm trying to encode/decode data using CryptoJS, as a preliminar test for the code I want to develop. This is the code I'm using for encrypting: <script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script> <script> var message = "Secret Message"; var key = CryptoJS.enc.Hex.parse('36ebe205bcdfc499a25e6923f4450fa8'); var iv = CryptoJS.enc.Hex.parse('be410fea41df7162a679875ec131cf2c'); // Encription. Works ok var encrypted = CryptoJS.AES.encrypt( message,key, { iv:

Converting Java's PBEWithMD5AndDES to JavaScript

此生再无相见时 提交于 2019-11-29 17:46:55
I'm trying to replicate the Java code in JavaScript. below is my Java code: public static String encrypt(String input) final byte[] SALT= { (byte) 0x21, (byte) 0x21, (byte) 0xF0, (byte) 0x55, (byte) 0xC3, (byte) 0x9F, (byte) 0x5A, (byte) 0x75 }; final int ITERATION_COUNT = 31; { if (input == null) { throw new IllegalArgumentException(); } try { KeySpec keySpec = new PBEKeySpec(null, SALT, ITERATION_COUNT); AlgorithmParameterSpec paramSpec = new PBEParameterSpec(SALT, ITERATION_COUNT); SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec); Cipher ecipher =

SHA512 hashes differ on android, php and javascript

和自甴很熟 提交于 2019-11-29 15:52:29
问题 I am using the SHA512 hash to transfer some encrypted data between my app and it's backend. However, I'm having a odd situation and have no idea what might be causing it. So, I've got following setups tested: Android 2x SHA512 Android 1x SHA512 -> CryptoJS 1x SHA512 PHP 2x SHA512 So, when I do the first 2x Android hashing, I get the same result as when I do the 1x android -> 1x cryptojs. However, when I do the PHP 2x, I get the same result as I get on the first Android pass, but the second

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

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

JavaScript File Hash Value Generate with Part of the file

房东的猫 提交于 2019-11-29 08:16:15
I am working with JavaScript to generate File HASH VALUE for unique file values. Kindly check the below code for the Hash Generation Mechanism Which works good. <script type="text/javascript"> // Reference: https://code.google.com/p/crypto-js/#MD5 function handleFileSelect(evt) { var files = evt.target.files; // FileList object // Loop through the FileList and render image files as thumbnails. for (var i = 0, f; f = files[i]; i++) { var reader = new FileReader(); // Closure to capture the file information. reader.onload = (function(theFile) { return function(e) { var span = document

How to properly sign a GET request to Amazon's ItemLookup using client-side JavaScript only?

无人久伴 提交于 2019-11-29 07:38:51
Here's what I have so far: function sha256(stringToSign, secretKey) { return CryptoJS.HmacSHA256(stringToSign, secretKey); } function getAmazonItemInfo(barcode) { var parameters = "Service=AWSECommerceService&" + "AWSAccessKeyId=" + appSettings.amazon.accessKey + "&" + "Operation=ItemLookup&" + "ItemId=" + barcode + "&Timestamp=" + Date.now().toString(); var stringToSign = "GET\n" + "webservices.amazon.com\n" + "/onca/xml\n" + parameters; var signature = "&Signature=" + encodeURIComponent(sha256(stringToSign, appSettings.amazon.secretKey)); var amazonUrl = "http://webservices.amazon.com/onca

How to decrypt an ArrayBuffer?

久未见 提交于 2019-11-28 23:22:53
问题 I've been trying to decrypt an ArrayBuffer object using CryptoJS, but so far it always returns a blank WordArray. The files (images) are encrypted in an iOS and Android app, sent to a server, and downloaded in this web app to be decrypted and displayed. The iOS and Android apps are able to decrypt the files without problems, so there's nothing wrong with the encryption process. The files are downloaded with an XMLHttpRequest with responseType set to arraybuffer . Here's my code so far: //