Giter Site home page Giter Site logo

Comments (10)

michaelpeterlee avatar michaelpeterlee commented on August 20, 2024 18

This error is triggered when you pass an object, rather than a string.

from cryptojs.

nezihsunman avatar nezihsunman commented on August 20, 2024 5

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.

sukeerthimogallapalli avatar sukeerthimogallapalli commented on August 20, 2024

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.

dmytro-kupriianov avatar dmytro-kupriianov commented on August 20, 2024

The same problem

from cryptojs.

Synat avatar Synat commented on August 20, 2024

The same problem

from cryptojs.

gocreating avatar gocreating commented on August 20, 2024

It's 2020 and I still get the same problem

from cryptojs.

JuanxCursed avatar JuanxCursed commented on August 20, 2024

Same problem here, even passing a simple string

from cryptojs.

yquintana avatar yquintana commented on August 20, 2024

Este error se activa cuando pasa un objeto, en lugar de una cadena.

it's true..

from cryptojs.

midhun1993 avatar midhun1993 commented on August 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.