Comments (10)
This error is triggered when you pass an object, rather than a string.
from cryptojs.
When the same thing happened to me I "stringify"
CryptoJS.AES.encrypt( JSON.stringify({
username: username,
text: text,
createdAt: new Date().getTime()
}), '123456').toString();
from cryptojs.
Hi
i am trying to decrypt private key but i am getting this error
/home/ahex/Desktop/tokenize.node/node_modules/crypto-js/core.js:272
words.length = Math.ceil(sigBytes / 4);
^
RangeError: Invalid array length
at WordArray.init.clamp (/home/ahex/Desktop/tokenize.node/node_modules/crypto-js/core.js:272:27)
at WordArray.init.concat (/home/ahex/Desktop/tokenize.node/node_modules/crypto-js/core.js:237:19)
My code :
var CryptoJS = require('crypto-js')
var cryptoSecret = '*************************'
var SenderPrivateKey = new bitcore.PrivateKey('testnet');
console.log(SenderPrivateKey)
//<PrivateKey: 8c6251ff3ee21e54bc15485c2ea8f7491501a7a684ecc08dfd95a993f048e06e, network: //testnet>
var a = CryptoJS.AES.encrypt(SenderPrivateKey, cryptoSecret)
from cryptojs.
The same problem
from cryptojs.
The same problem
from cryptojs.
It's 2020 and I still get the same problem
from cryptojs.
Same problem here, even passing a simple string
from cryptojs.
Este error se activa cuando pasa un objeto, en lugar de una cadena.
it's true..
from cryptojs.
For me this issue occurred due to the type number
.
So I did like this:
function transformToSafePayload(payload) {
if (typeof payload == 'object') {
return JSON.stringify(payload);
}
if (typeof payload != 'string') {
return payload.toString();
}
return payload;
}
CryptoJS.AES.encrypt(transformToSafePayload({
username: username,
text: text,
createdAt: new Date().getTime()
}), '123456').toString();
from cryptojs.
Related Issues (13)
- Offer to help with maintenance
- This project is not updated for 2 years
- Javascript sample code
- Add a license
- Unexpected String when requiring
- can not import in react-native
- TypeError: Cannot read property 'decrypt' of undefined
- Functionality doesn't match CyrptoJS, no documented alternative HOT 5
- Where is RC4 support? HOT 3
- Load with requirejs HOT 4
- Does not work in the browser so don't claim it...... HOT 1
- Examples are not in Javascript
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cryptojs.