Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

545
Views
TypeError: CryptoJS.SHA256 no es una función

 import * as CryptoJS from 'crypto-js'; import * as ecdsa from 'elliptic'; import * as _ from 'lodash' class Transaction { id = null; constructor(id, txIns, txOuts) { this.id = id; this.txIns = txIns; this.txOuts = txOuts; } } function getTransactionId (Transaction) { const txInContent = Transaction.txIns.txOutId + Transaction.txIns.txOutIndex; // const txInContent = Transaction.TxIN.map((TxIN) => TxIN.txOutId + TxIN.txOutIndex).reduce((a, b) => a + b, ''); const txOutContent = Transaction.txOuts.amount + Transaction.txOuts.address; // const txOutContent = Transaction.TxOut.map((TxOUT) => txOut.amount + txOut.address).reduce((a, b) => a + b, ''); return (txInContent + txOutContent).toString(); } class TxIN { txOutId = null; txOutIndex = null; signature = null; constructor(txOutId, txOutIndex, signature) { this.txOutId = txOutId; // Previous transaction ID this.txOutIndex = txOutIndex; this.signature = signature; // Sender's signature } } class TxOUT { amount = null; address = null; constructor(amount, address) { this.amount = amount; // Amount value of output this.address = address; // Receiver's address } } let testOut = new TxOUT(10, "tb1****************************ntxt"); let testIn = new TxIN("tb******************************tntxt", 0, "gg") let testTrans = new Transaction("1329***********************1e99ba8", testIn, testOut); var test = 'GG'; console.log(test); var t = CryptoJS.SHA256(test);

Estoy usando CryptoJS.SHA256() en mi proyecto de JavaScript. Pero muestra el "TypeError: CryptoJS.SHA256 no es una función". Y ya importé el 'crypto-js'. Cuando traté de iniciar sesión en crypto. Encontré el "SHA256: [Función (anónima)]". Pero el TypeError no se puede resolver. ¿Hay algo que cometo un error?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

prueba estos:

npm install @types/node --save-dev para instalar definiciones de NodeJS

 npm install --save @types/crypto-js

En el archivo tsconfig.ts agregue lo siguiente:

 "files": [ "./node_modules/@types/node/index.d.ts" ]

Importa la biblioteca donde quieras usarla con import

 import * as sha256 from 'crypto-js/sha256';

o con sintaxis de importación especial

 import sha256 = require("crypto-js/sha256");
about 4 years ago · Juan Pablo Isaza Report

0

intenta conseguirlo asi:

 var SHA256 = require("crypto-js/sha256"); console.log(SHA256('my message'));

aquí está la demostración en ejecución: https://replit.com/@slash851/crypto-js-test#index.js

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!