brix / crypto-js Goto Github PK
View Code? Open in Web Editor NEWJavaScript library of crypto standards.
License: Other
JavaScript library of crypto standards.
License: Other
Other packages use crypto-js for relying on cryptography (e.g. passport-local-mongoose), so adding support for argon2 or scrypt in this package will make those algorithms available to many projects.
Simply add crypto-js.js
on a page and observe the following error:
Uncaught TypeError: Cannot read property 'Word' of undefined
crypto-js.js:2156 (anonymous function)
crypto-js.js:2214 (anonymous function)
crypto-js.js:12 C
crypto-js.js:14 (anonymous function)
Thanks for providing such a wonderful library.
Here is my situation, I have a function to decrypt aes content.
/**
* decryptAES content
* @param content
* @param pass the password
* @return content or false when wrong password
*/
function decryptAES(content, pass) {
var result = false;
try {
var bytes = CryptoJS.AES.decrypt(content, pass);
var content = bytes.toString(CryptoJS.enc.Utf8);
console.log(content);
if (content != '') {
result = content;
}
} catch (e) {}
return result;
}
But, if the content is empty, the function return false, but the password is correct. So, is there a better way to check the password is correct? Thanks for any suggestions.
i have two string fields in database, both of them are encrypted by cryptojs v3.0.2 in client browser. and the code is like this:
CryptoJS.AES.encrypt(txt, key).toString()
today i got a Malformed Utf-8 data error when decrypting in browsers by cryptojs v3.0.2, one of them (named A)works fine,the other (named B) does not.
so i tried to decrypt them in node.js and browsers using crypto-js v3.1.2, the decrypt code is like this:
CryptoJS.AES.decrypt(txt, key).toString(CryptoJS.enc.Utf8)
the results is werid (the result from browser and node.js is the same).
- i got an empty string when decrypt A
- i got the same error when decrypt B
so the behavior is not the same between v3.0.2 and v3.1.2.
could you help me
In the last version v3.1.3, I see that you have moved some files.
This is definitely a breaking change. You should increment the minor version number in order to respect semver.
And probably delete tag v3.1.3 and create a new one 3.2.0.
When calling Hmac functions in this library, I get the following stack trace:
TypeError: undefined is not a function
at Object.C_algo.HMAC.Base.extend.init (<path>/node_modules/crypto-js/hmac.js:58:18)
at Object.HmacSHA512 (<path>/node_modules/crypto-js/core.js:726:25)
<rest of stack trace is my app>
I tried HmacSHA512
and HmacSHA1
, using the example provided in the README. Both threw this error. At line 58 in hmac.js, the method 'clamp' is called on key: key.clamp()
. It appears this is the undefined function referenced in the stack trace. I'm not sure what this should be replaced with. This is the relevant code in my application:
const crypto = require('crypto-js');
const key = crypto.HmacSHA512(key, secret);
I dug around, but I wasn't able to figure out why my example is not running. I saw the example for aes at the bottom of the file https://github.com/brix/crypto-js/blob/master/aes.js#L218.
var CryptoJS = require("crypto-js");
var message = 'test';
var key = '1234abcd0998ijdf';
var cfg = {};
var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
console.log(plaintext);
The output is not plain text, its:
{ words: [ 1952805748, 202116108, 202116108, 202116108 ],
sigBytes: 4 }
Calling toString()
on the object returns 74657374
. Any idea where I'm going wrong?
I was wondering what kind of relationship exists, if any, between this library and sytelus/CryptoJS. Google shows your library and sytelus's as first ones, and it seems that both are based on Jeff Mott's crypto-js. Would it be possible to merge the two libraries, so that features and updates do not make the two libraries diverge any further and there is one, robust library holding a full cryptographic suite?
Thanks,
Sam
This is not generating sufficiently random bytes. Math.random was never intended for use in cryptographic applications.
see:
https://code.google.com/p/chromium/issues/detail?id=246054
Due to a database issue on GitHub I double-posted this issue. It can be removed.
How do I get encoding in lowercase hexits?
I have tried to add separate components:
<script type="text/javascript" src="./bower_components/crypto-js/core.js"></script>
<script type="text/javascript" src="./bower_components/crypto-js/enc-base64.js"></script>
<script type="text/javascript" src="./bower_components/crypto-js/md5.js"></script>
<script type="text/javascript" src="./bower_components/crypto-js/sha1.js"></script>
<script type="text/javascript" src="./bower_components/crypto-js/hmac.js"></script>
<script type="text/javascript" src="./bower_components/crypto-js/evpkdf.js"></script>
<script type="text/javascript" src="./bower_components/crypto-js/cipher-core.js"></script>
<script type="text/javascript" src="./bower_components/crypto-js/mode-ecb.js"></script>
<script type="text/javascript" src="./bower_components/crypto-js/aes.js"></script>
else {
// Global (browser)
factory();
}
}(this, function (CryptoJS) {
(function () {
// Shortcuts
var C = CryptoJS;
var C_lib = C.lib;
factory()
is called without parameters, which means CryptoJS
will be undefined
in the factory body. Which lead to errors like:
Uncaught TypeError: Cannot read property 'lib' of undefined - enc-base64.js:19
Would you consider using ES6 modules?
Related three.js just moved to ES6 modules mrdoob/three.js#9310
hello,
i tried to use AMD version and link just a aes.js file and method "encrypt" returns with error
cipher-core.js:775 Uncaught TypeError: Cannot read property 'create' of undefined
example of my code:
define([
'crypto-js/aes',
'crypto-js/enc-utf8'
], function(
AES,
Utf8
) {
var cipherText = AES.encrypt(text,passphrase).toString();
})
i found it can be fixed in file cipher-core.js by adding "./evpkdf"
define(["./core", "./evpkdf"], factory);
Hi, have you considered making this library require
able?
Hi,
Where/how can I find a list of the modules.. ?
For example, I want crypto-js/aes but I also want WordArray... but don't know how I can include(?) / access wordarray though only including aes module.. etc?
Thanks,
Flibbr
var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase");
var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase");
console.log(decrypted)
the out is : "4d657373616765" not equal to "Message"
I dont know much about the AES encryption and decryption, im only a js developer and i studied somewhere aes encryption will done on large files using chunks, so im thinking there is a way to publish the progress to variable where encryption/decyrption is going. So that we can show some percentage to users about the encryption/decryption
Hi,
I installed crypro js and was trying to do AES encrypt as follows.
var userAES = CryptoJS.AES.encrypt(JSON.stringify(info.user), 'thisisakey');
But it says "Unhandled rejection TypeError: Converting circular structure to JSON"
There is a bug in src/core.js that causes these (HmacSHA224. HmacSHA384) to return incorrect results.
I forked the repo and applied a fix from:
https://code.google.com/p/crypto-js/issues/detail?id=84
Perhaps you would consider this and update your bower to match; there are already too many versions of cryptojs in bower and I would rather not create another one ๐
given
import pbkdf2 from 'crypto-js/pbkdf2'
import crypto from 'crypto-js'
pbkdf2(password, salt, {
iterations: 10,
hasher: crypto.algo.SHA256,
keySize: 256
})
how do I change this code to import only the SHA256 algo without carrying the whole library around in my bundle?
It would be so greatly appreciated if crypto-js were added to https://github.com/cljsjs/packages so it could be used within clojurescript more easily. Thanks for the excellent project.
I installed with bower install crypto-js --save
But i do not know how to add or use in my angular application
Please add these files with full license text to the NPM distribution packages. Unfortunately, from the legal standpoint, simply specifying the name of the license is not enough, because it's unclear where to get the EXACT (legally binding) text of that license. This is a major roadblock on our way to using the module, seriously.
Thanks a lot for the great code, and thanks in advance for fixing this blocker.
Hi there.
could you be so kind to describe me something. I need to encrypt some string with secret passphrase with RC4 or other algorithm which is decryptable, then keep the encrypted string (not the object!) in the database and later decrypt it.
I am trying to do it with RC4
var encrypted = CryptoJS.RC4.encrypt("Message", "Secret Passphrase", { format: JsonFormatter }); console.log("encrypted"); console.log(encrypted); alert(encrypted); json=JSON.stringify(encrypted); console.log("stringify encrypted"); console.log(json); str=encrypted.toString(); console.log(encrypted.toString()); var decrypted = CryptoJS.RC4.decrypt(encrypted, "Secret Passphrase", { format: JsonFormatter }); decrypted.toString()
But I am not geting word Message. Why?
hello , if i only want aes , can i delete other files? how?
I have this json:
"hashMix": {
"words": [
-699555019,
-1289234862,
1459631473,
-802739593
],
"sigBytes": 16
}
And I want to parse it to the Hash (Base) object, how is the best way to do it?
I'm developing a app which needs to RSA Encryption does crypto-js have it and I can use with Angular?
error parsing json SyntaxError: Unexpected token s
Node.js v0.10.26 npm windows
The NPM source is uglified, which makes it difficult to debug errors when using it.
I think it's best to not uglify the package, and people interested in doing so for browser usage can then run it through browserify and uglify when needed.
This is related to bitcoinjs/bitcoinjs-lib#57
I'm using crypto-js without nodejs nor require nor whatever.
This works quite well.
It would be nice if the documentation would stop pretending this is a requirement. I guess it frightens people. Plus there is an example on https://github.com/brix/crypto-js that starts with var CryptoJS = require("crypto-js");
that makes things look impossible to use, especially with free software.
Roll ups like the one on that were available on google were much better in my opinion...
Hello,
i receive this error sometime,
Input strings must be a multiple of the segment size 16 in length
Any idea's whats going on?
result = CryptoJS.AES.encrypt(serialized, key, {
iv: iv,
mode: CryptoJS.mode.CFB,
});
After migrate from google code the structure has changed. Now there are issues to integrate the new source (github) in jsdelivr CDN.
Please provide a old structured release or change to a new major version.
CryptoJS.AES.decrypt.prototype.constructor
function (ciphertext, key, cfg) { return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); }
but what makes cfg
?
thx
I'm doing this on my node server with crypto-js:
var secret = CryptoJS.enc.Base64.stringify( CryptoJS.HmacSHA256(nonce, "my_secret_key") );
and it's "working", but getting different values than doing the same on JS with the original CryptoJS (client side).
Anyone know what I can do to produce the same results? I originally moved it to node so that I could hide my secret key, but having trouble returning what the original code was expecting (different values)
All of a sudden, I'm getting a 404 error when installing crypto-js through bower. This is happening both on my local machine (OSX) and inside a docker VM (debian stretch). I get the following trace when running bower install crypto-js --verbose
:
$ bower install crypto-js --verbose
bower animate.scss#* not-cached https://github.com/ianstormtaylor/animate.sass.git#*
bower animate.scss#* resolve https://github.com/ianstormtaylor/animate.sass.git#*
bower api-console#~2.0.5 cached https://github.com/mulesoft/api-console.git#2.0.5
bower api-console#~2.0.5 validate 2.0.5 against https://github.com/mulesoft/api-console.git#~2.0.5
bower font-awesome#~4.2.0 cached https://github.com/FortAwesome/Font-Awesome.git#4.2.0
bower font-awesome#~4.2.0 validate 4.2.0 against https://github.com/FortAwesome/Font-Awesome.git#~4.2.0
bower skeuocard#~1.1.0 cached https://github.com/kenkeiter/skeuocard.git#1.1.0
bower skeuocard#~1.1.0 validate 1.1.0 against https://github.com/kenkeiter/skeuocard.git#~1.1.0
bower card#^1.3.2 cached https://github.com/jessepollak/card.git#1.3.2
bower card#^1.3.2 validate 1.3.2 against https://github.com/jessepollak/card.git#^1.3.2
bower Materialize#^0.97.7 cached https://github.com/Dogfalo/materialize.git#0.97.7
bower Materialize#^0.97.7 validate 0.97.7 against https://github.com/Dogfalo/materialize.git#^0.97.7
bower crypto-js#* cached https://github.com/brix/crypto-js.git#3.1.6
bower crypto-js#* validate 3.1.6 against https://github.com/brix/crypto-js.git#*
bower animate.scss#* checkout master
bower crypto-js#* cached https://crypto-js.googlecode.com/files/CryptoJS%20v3.1.2.zip
bower crypto-js#* validate https://crypto-js.googlecode.com/files/CryptoJS%20v3.1.2.zip#*
bower vkbeautify#ecfc3b9e2b911ad8ebd49600c4089aca30619f29 cached git://github.com/vkiryukhin/vkBeautify.git#ecfc3b9e2b
bower vkbeautify#ecfc3b9e2b911ad8ebd49600c4089aca30619f29 validate ecfc3b9e2b against git://github.com/vkiryukhin/vkBeautify.git#ecfc3b9e2b911ad8ebd49600c4089aca30619f29
bower raml-js-parser#e1513e34388d6bb6558f5cb5b221c19f90e225e5 cached git://github.com/raml-org/raml-js-parser.git#e1513e3438
bower raml-js-parser#e1513e34388d6bb6558f5cb5b221c19f90e225e5 validate e1513e3438 against git://github.com/raml-org/raml-js-parser.git#e1513e34388d6bb6558f5cb5b221c19f90e225e5
bower angular-highlightjs#~0.3.2 cached https://github.com/pc035860/angular-highlightjs.git#0.3.3
bower angular-highlightjs#~0.3.2 validate 0.3.3 against https://github.com/pc035860/angular-highlightjs.git#~0.3.2
bower angular-marked#0.0.18 cached https://github.com/Hypercubed/angular-marked.git#0.0.18
bower angular-marked#0.0.18 validate 0.0.18 against https://github.com/Hypercubed/angular-marked.git#0.0.18
bower angular-ui-codemirror#0.1.6 cached https://github.com/angular-ui/ui-codemirror.git#0.1.6
bower angular-ui-codemirror#0.1.6 validate 0.1.6 against https://github.com/angular-ui/ui-codemirror.git#0.1.6
bower angular#~1.3.17 cached https://github.com/angular/bower-angular.git#1.3.20
bower angular#~1.3.17 validate 1.3.20 against https://github.com/angular/bower-angular.git#~1.3.17
bower angular-sanitize#~1.3.17 cached https://github.com/angular/bower-angular-sanitize.git#1.3.20
bower angular-sanitize#~1.3.17 validate 1.3.20 against https://github.com/angular/bower-angular-sanitize.git#~1.3.17
bower codemirror#~3.15.0 cached https://github.com/marijnh/CodeMirror.git#3.15.0
bower codemirror#~3.15.0 validate 3.15.0 against https://github.com/marijnh/CodeMirror.git#~3.15.0
bower FileSaver#* cached https://github.com/eligrey/FileSaver.js.git#1.3.2
bower FileSaver#* validate 1.3.2 against https://github.com/eligrey/FileSaver.js.git#*
bower highlight-js#~7.0.1 cached https://github.com/isagalaev/highlight.js.git#7.0.1
bower highlight-js#~7.0.1 validate 7.0.1 against https://github.com/isagalaev/highlight.js.git#~7.0.1
bower marked#~0.3.1 cached https://github.com/chjj/marked.git#0.3.6
bower marked#~0.3.1 validate 0.3.6 against https://github.com/chjj/marked.git#~0.3.1
bower slug#~0.8.0 cached https://github.com/dodo/node-slug.git#0.8.0
bower slug#~0.8.0 validate 0.8.0 against https://github.com/dodo/node-slug.git#~0.8.0
bower jquery#>=1.5 cached https://github.com/jquery/jquery-dist.git#3.1.0
bower jquery#>=1.5 validate 3.1.0 against https://github.com/jquery/jquery-dist.git#>=1.5
bower jquery#~2.1.1 cached https://github.com/jquery/jquery-dist.git#2.1.4
bower jquery#~2.1.1 validate 2.1.4 against https://github.com/jquery/jquery-dist.git#~2.1.1
bower velocity#~1.1.0 cached https://github.com/julianshapiro/velocity.git#1.1.0
bower velocity#~1.1.0 validate 1.1.0 against https://github.com/julianshapiro/velocity.git#~1.1.0
bower jszip#~2.0.0 cached https://github.com/Stuk/jszip.git#2.0.0
bower jszip#~2.0.0 validate 2.0.0 against https://github.com/Stuk/jszip.git#~2.0.0
bower raml-client-generator#~0.0.7 cached https://github.com/mulesoft/raml-client-generator.git#0.0.7
bower raml-client-generator#~0.0.7 validate 0.0.7 against https://github.com/mulesoft/raml-client-generator.git#~0.0.7
bower crypto-js#* new version for https://crypto-js.googlecode.com/files/CryptoJS%20v3.1.2.zip#*
bower crypto-js#* resolve https://crypto-js.googlecode.com/files/CryptoJS%20v3.1.2.zip#*
bower crypto-js#* download https://crypto-js.googlecode.com/files/CryptoJS%20v3.1.2.zip
bower animate.scss#* resolved https://github.com/ianstormtaylor/animate.sass.git#62aebcf7c8
bower crypto-js#* EHTTP Status code of 404
Stack trace:
Error: Status code of 404
at createError (/usr/local/lib/node_modules/bower/lib/util/createError.js:4:15)
at Request.<anonymous> (/usr/local/lib/node_modules/bower/lib/util/download.js:91:36)
at emitOne (events.js:82:20)
at Request.emit (events.js:169:7)
at Request.onRequestResponse (/usr/local/lib/node_modules/bower/lib/node_modules/request/request.js:951:10)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:430:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23)
at TLSSocket.socketOnData (_http_client.js:320:20)
From previous event:
at RetryOperation._fn (/usr/local/lib/node_modules/bower/lib/util/download.js:41:10)
at RetryOperation.attempt (/usr/local/lib/node_modules/bower/lib/node_modules/retry/lib/retry_operation.js:56:8)
at download (/usr/local/lib/node_modules/bower/lib/util/download.js:36:15)
at UrlResolver._download (/usr/local/lib/node_modules/bower/lib/core/resolvers/UrlResolver.js:133:12)
at UrlResolver._resolve (/usr/local/lib/node_modules/bower/lib/core/resolvers/UrlResolver.js:96:17)
Console trace:
Error
at StandardRenderer.error (/usr/local/lib/node_modules/bower/lib/renderers/StandardRenderer.js:81:37)
at Logger.<anonymous> (/usr/local/lib/node_modules/bower/lib/bin/bower.js:110:26)
at emitOne (events.js:77:13)
at Logger.emit (events.js:169:7)
at Logger.emit (/usr/local/lib/node_modules/bower/lib/node_modules/bower-logger/lib/Logger.js:29:39)
at /usr/local/lib/node_modules/bower/lib/commands/index.js:48:20
at _rejected (/usr/local/lib/node_modules/bower/lib/node_modules/q/q.js:844:24)
at /usr/local/lib/node_modules/bower/lib/node_modules/q/q.js:870:30
at Promise.when (/usr/local/lib/node_modules/bower/lib/node_modules/q/q.js:1122:31)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/bower/lib/node_modules/q/q.js:788:41)
System info:
Bower version: 1.7.9
Node version: 4.4.7
OS: Darwin 15.6.0 x64
i try to get a md5 string by the follow code, but i get strange thing.
> var crypto = require("crypto-js");
> crypto.MD5("test")
{ words: [ 160394189, 1176621939, -891400573, 640136438 ],
sigBytes: 16 }
>
I am having a scenario where i want to secure the JSON data which i am sending and storing at the client side, and i also want that, that data should be protected, The way to protect this data i suppose is encryption of the data but because the decryption logic and key is also at the client side (to decrypt the encrypted JSON data).
So to protect it i was wondering if we can set something like expiration time of key,
The way i was thinking this is to work that if someone is encrypting the data with the key then encrypted data must have some intelligence that after a period of time this data cannot be decrypted with the key with which it was encrypted(or may be cannot be decrypted at all).
is it possible? i suppose yes , and i don't it is there in the library now.
so i am asking to all members to please provide this facility in this library, or if it is not possible(which i suppose is not) or is not gonna solve a problem please justify.
Thanks.
I want to use this for encrypting at client side & decrypting at server side, while sending password.
Which key (Public or Private) to encrypt or which key (Public or Private) to decrypt
var secret = CryptoJS.ASE.encrypt('user','secret'); // U2FsdGVkX19oU61BktfTADc18gnyiSOCV8DX+F5Plf8=
var ulog = CryptoJS.RC4.decrypt(secret,'secret'); // 75736572
decoding on all algorithms returns 75736572
Here's my code :
`var CryptoJS = require("crypto-js");
var key = '5024D151B40D7F5724B5563A316938C5';
var aBlock = [ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
var sBlock = [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
var sBlock_str64 = CryptoJS.AES.encrypt(aBlock.join(""), key);
console.log("sBlock_str64 : "+sBlock_str64);
var sBlock = CryptoJS.enc.Base64.parse(sBlock_str64);
console.log(sBlock);`
I have an issue with crypto-js enc.Base64.parse()
In Node-Red : TypeError: base64Str.indexOf is not a function
In https://tonicdev.com/npm/crypto-js# : TypeError : undefined is not a function
Have you ever met such an error with enc-base64.js ?
Extract :
`/**
* Converts a Base64 string to a word array.
*
* @param {string} base64Str The Base64 string.
*
* @return {WordArray} The word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.enc.Base64.parse(base64String);
*/
parse: function (base64Str) {
// Shortcuts
var base64StrLength = base64Str.length;
var map = this._map;
// Ignore padding
var paddingChar = map.charAt(64);
if (paddingChar) {
var paddingIndex = base64Str.indexOf(paddingChar);
if (paddingIndex != -1) {
base64StrLength = paddingIndex;
}
}
// Convert
var words = [];
var nBytes = 0;
for (var i = 0; i < base64StrLength; i++) {
if (i % 4) {
var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
var bitsCombined = bits1 | bits2;
words[nBytes >>> 2] |= (bitsCombined) << (24 - (nBytes % 4) * 8);
nBytes++;
}
}
return WordArray.create(words, nBytes);
},
_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
};`
Thanks in advance !
please add bower.json to make package installable via bower package manager
I'm trying to use crypto-js in react but I have a problem.
My action is as follows :
export function userLogin(userData){
return function(dispatch){
userApi.userExists(userData)
.then((response) => {
const tokenEnc = CryptoJS.AES.encrypt(response, 'token');
//If request is good
// - Update state to indicate if user is authenticated
dispatch({type: AUTH_USER});
localStorage.setItem('token', tokenEnc);
browserHistory.push(`/users`);
}).catch((err) => {
dispatch(authError("The user with the given emailaddress and password doesn't exists. The error is : " + err));
});
};
}
And the userExists is as follows :
class UserApi {
static userExists(userData) {
return new Promise((resolve, reject) => {
const userFound = users.some(function (user) {
return ((user.email === userData.email) && (user.password === userData.password));
});
if (userFound) {
const obj = users.filter(function ( obj ) {
return obj.email === userData.email;
})[0];
resolve(obj.email);
} else {
reject("Error! User not found!");
}
});
}
}
export default UserApi;
The problem is when I first time try to log in with the correct credentials I get error TypeError: Cannot read property 'salt' of null.
It can't decrypt it. With the debugger I see that
localStorage.setItem('token', tokenEnc);
isn't executed first time.
If I click again on login, it works perfect.
Any advice?
# python2.7.12
from Crypto.Cipher import AES
import base64
KEY = 'ABCDEF1234567890'
IV = 'ABCDEF1234567890'
aes = AES.new(KEY, AES.MODE_ECB, IV)
user = 'root'
user = user + ' ' * (16-len(user))
en_user = aes.encrypt(user)
en_user = base64.b64encode(en_user)
#This is output
print 'en_user', en_user # en_user tPL98ukMrLRcVXPk6zQMFQ==
/*javascript*/
KEY = 'ABCDEF1234567890';
IV = 'ABCDEF1234567890';
var user='root';
for(tmp=0;tmp<16-user.length;tmp++)
{
user = user + ' ';
}
var en_user = CryptoJS.AES.encrypt(user, KEY, {iv:IV, mode:CryptoJS.mode.ECB,
padding:CryptoJS.pad.NoPadding}).toString();
en_user = btoa(en_user);
//This is output
console.log(en_user); //VTJGc2RHVmtYMS83UDRRcnpUWDFJUlJlblRTZFlvenRta2M9
What's wrong?
How to use crypto-js to sign string with RSA-SHA1?
There is an typing error at the end of file "enc-utf8.js". It is "return e.enc.Utf1" and expected to be "return e.enc.Utf8".
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.