How to decrypt message with CryptoJS AES. I have a working Ruby example

后端 未结 5 1994
萌比男神i
萌比男神i 2020-12-01 01:57

I\'m able to decrypt AES encrypted message with Ruby like this:

require \'openssl\'
require \'base64\'

data = \"IYkyGxYaNgHpnZWgwILMalVFmLWFgTCHCZL9263NOcfS         


        
5条回答
  •  無奈伤痛
    2020-12-01 02:02

    for the hex2a provided by another user, it may not working if ascii code is over 128 (i.e text contains chinese , etc)

    you can use the follow to return proper unicode

    function hex2a(hex) {
        var str = '';
        for (var i = 0; i < hex.length; i += 2){
    
            var dec = parseInt(hex.substr(i, 2), 16);
            character = String.fromCharCode(dec);
    
    
            if (dec > 127)
                character = "%"+hex.substr(i,2);
    
            str += character;
    
        }
    
        return decodeURI(str);
    }
    

提交回复
热议问题