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

341
Views
JavaScript: cadena descriptiva que se ha cifrado en C#

Creé este método para cifrar la cadena con una clave:

 public static string EncryptString(string key, string plainText) { byte[] iv = new byte[16]; byte[] array; using (Aes aes = Aes.Create()) { aes.Key = Encoding.UTF8.GetBytes(key); aes.IV = iv; ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV); using (MemoryStream memoryStream = new MemoryStream()) { using (CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, encryptor, CryptoStreamMode.Write)) { using (StreamWriter streamWriter = new StreamWriter((Stream)cryptoStream)) { streamWriter.Write(plainText); } array = memoryStream.ToArray(); } } } return Convert.ToBase64String(array); }

Pero también necesito este método en JS, para descifrar también la misma cadena.

me pregunto sobre

AES, Codificación.UTF8.GetBytes, ICryptoTransform, Cryptostreammode y MemoryStream.

¿Existen en JS?

¿ES este método incluso utilizable en JS?

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

0

Usando su código C# para encriptar una cadena a través public static string EncryptString(string key, string plainText) obtengo el siguiente resultado:

 EncryptString("xxxxxxxxxxxxxxxx", "Hello World") -> "yM377gXxX5Du71hgkPH+Fg=="

Para revertir esto, puede consultar este código Javascript:

 const key = "xxxxxxxxxxxxxxxx"; const msg = "yM377gXxX5Du71hgkPH+Fg=="; const decrypted = CryptoJS.AES.decrypt( msg, CryptoJS.enc.Utf8.parse(key), { mode: CryptoJS.mode.ECB } ); console.log(decrypted.toString(CryptoJS.enc.Utf8));
 <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>

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!