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

285
Views
TypeError: crypto.createCipheriv no es una función

vite+vue3 usa aes-cross para informar: TypeError: crypto.createCipheriv no es una función Versión: "vue": "^3.2.23", "vite": "^2.6.4", "aes-cross": " ^1.0.9",

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

0

Para que las crypto funcionen en el navegador, sigue las instrucciones a continuación 👇

  1. Agregar dependencias

yarn add stream-browserify browserify-zlib events process util buffer

  1. Configurar vite.config.js
 import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' // https://vitejs.dev/config/ export default defineConfig({ plugins: [vue()], resolve: { alias: { process: "process/browser", stream: "stream-browserify", zlib: "browserify-zlib", util: 'util' } } })
  1. Agregue JS a index.html
 <!-- [...] --> <div id="root"></div> <!-- node // crypto --> <script>window.global = window;</script> <script type="module"> import { Buffer } from "buffer/"; // <-- no typo here ("/") import process from "process"; import EventEmitter from "events"; window.Buffer = Buffer; window.process = process; window.EventEmitter = EventEmitter; </script> <!-- [...] -->
  1. Agregue importaciones a App.vue y función de prueba

en App.vue :

 import crypto from 'crypto-browserify' import { Buffer } from 'buffer/' // <-- no typo here ("/") // test crypto function crypt() { // Node.js program to demonstrate the // crypto.createCipheriv() method const iv = crypto.randomBytes(16); const key = crypto.pbkdf2Sync("foobar", "salt", 1000, 32, 'sha512'); const cipher = crypto.createCipheriv('aes-256-gcm', key, iv); var text = crypto.randomBytes(200) var ourCipherText = Buffer.concat([cipher.update(text), cipher.final()]) console.log("ciphered text:", ourCipherText.toString('hex')) return ourCipherText.toString('hex'); } [...]

Resultado ✅

captura de pantalla del navegador criptográfico

about 4 years ago · Juan Pablo Isaza Report

0

La función crypto.createCipheriv es una función exclusiva de node.js, lo que significa que no está disponible en el navegador como en una aplicación Vue. Debe investigar SubtleCrypto , que proporciona funciones web nativas para muchos propósitos de encriptación como AES. Como siempre, se debe tener en cuenta que se debe ser muy cuidadoso y metódico al usar primitivas criptográficas de bajo nivel, especialmente en lo que respecta al cifrado. Esta página proporciona más ejemplos de cifrado AES específicamente.

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!