welkinxie / aescipher-java Goto Github PK
View Code? Open in Web Editor NEWAES encryption working between Objective-C and Java.
License: MIT License
AES encryption working between Objective-C and Java.
License: MIT License
var iv = "16-Bytes--String";
function encryptAES(content, key) {
var AES = CryptoJS.AES;
var ivStr = CryptoJS.enc.Utf8.parse(iv);
var keyStr = CryptoJS.enc.Utf8.parse(key);
var text = AES.encrypt(content, keyStr, {
iv: ivStr,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
return text.toString();
}
function decryptAES(ciphertext, key) {
var AES = CryptoJS.AES;
var ivStr = CryptoJS.enc.Utf8.parse(iv);
var keyStr = CryptoJS.enc.Utf8.parse(key);
var bytes = AES.decrypt(ciphertext, keyStr, {
iv: ivStr,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
var plaintext = bytes.toString(CryptoJS.enc.Utf8);
return plaintext.toString();
}
Use brix/crypto-js lib.
QML code: qml-snippet/code/crypto-qml
我查看了源码,您源码中默认的编码格式是UTF-8.
而且大部分情况加解密是没问题的.我们只有一个用户出现这种情况.出现的乱码是这样的.
解密后的乱码是这样的.
�h��=�+�l
@����(n�!��
*�-��r� ��_C��Mӛ�9���<��jD��^h��vP؆n��l��0��b�ύI�K�JJ��z����X��`l�T����=����XK����1��n�Y%ƍ��r�6�Сk���2���R���o���D������%��M�!Y��=���̽,w����
不知道作者是否有遇到这个情况.
Base64.encodeToString(encryptedBytes, DEFAULT);
Base64.decode(content, DEFAULT);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.