Questions tagged [window.crypto]

JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption.

JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. http://www.w3.org/TR/WebCryptoAPI/

16 questions
59
votes
18 answers

How to use Jest to test functions using crypto or window.msCrypto

When running unit tests with Jest in react the window.crypto API is causing problems. I haven't found a way to incorporate crypto in Jest without installing other packages which is something I can't do. So without using another npm package is there…
CoderLee
  • 3,079
  • 3
  • 25
  • 57
26
votes
3 answers

How to get HMAC with Crypto Web API

How can I get HMAC-SHA512(key, data) in the browser using Crypto Web API (window.crypto)? Currently I am using CryptoJS library and it is pretty simple: CryptoJS.HmacSHA512("myawesomedata", "mysecretkey").toString(); Result is…
Stepan Snigirev
  • 816
  • 1
  • 7
  • 11
14
votes
2 answers

What is wrong with crypto.getRandomValues in Internet Explorer 11?

The following code generates 3 random numbers by using window.crypto.getRandomValues. According to the developer's documentation (Microsoft MSDN and Mozilla MDN), this should work both in IE and in Chrome. But in reality it works only in Chrome, not…
Matt
  • 25,467
  • 18
  • 120
  • 187
5
votes
1 answer

window.crypto returns 352 bit key instead of 256?

I'm trying to encrypt some text using window.crypto: await crypto.subtle.encrypt(algorithm, key, dataArrayBuffer).catch(error => console.error(error)); However I get this error AES key data must be 128 or 256 bits. I'm using PBKDF2 to create a 256…
now_world
  • 940
  • 7
  • 21
  • 56
5
votes
1 answer

How do I use TextEncoder in IE11?

I'm trying to hash a string. But what is the alternative for function TextEncoder in IE11 and Safari? var string = "foobar"; window.crypto.subtle.digest( { "name": "SHA-256" }, new TextEncoder("utf-8").encode(string)).then(function…
wubbewubbewubbe
  • 711
  • 1
  • 9
  • 20
2
votes
1 answer

js signature on chrome with OS keystore

W3C is working on a http://www.w3.org/TR/WebCryptoAPI/ to define a way to generate digital signatures, encrypton and so on from javascript. Basically defines a new object crypto inside a window object in DOM which must provide javascript with…
albciff
  • 18,112
  • 4
  • 64
  • 89
1
vote
1 answer

Encrypt with 'window.crypto.subtle', decrypt in c#

I want to encrypt with window.crypto.subtle and decrypt in C#. The crypt / decrypt in js are working. In C#, The computed authentification tag don't match the input. I don't know if I can put any 12 bytes as salt nor if I need to derive the…
Vincent
  • 510
  • 1
  • 5
  • 23
1
vote
1 answer

Decrypt an RSA message from browser with window.crypto.subtle APIs

I'm trying to decode an RSA 2048 bit message encoded with a public key using the corresponding private key. The environment is google chrome and I'm using the window.crypto.subtle APIs. I generated the key couple and encoded the message using…
1
vote
1 answer

Decrypt a AES-CTR 256 bits message from browser with window.crypto.subtle APIs

I need to decrypt in the browser a message encoded with AES-CTR 256 bits (encoded using OpenSSL). Using OpenSSL I get something like: key=189BBBB00C5F1FB7FBA9AD9285F193D1771D7611CB891E5C1F4E24C20E50FB1D iv…
Daniele Pallastrelli
  • 2,430
  • 1
  • 21
  • 37
1
vote
1 answer

Javascript password generator adding spaces and failing tests

I'm trying to build a password generator which creates passwords conforming to: Minimum 8 characters in length, Maximum 40 characters in length Must contain at least 1 uppercase, lowercase, number and symbol I'm avoiding Math.random out of…
1
vote
0 answers

save window.crypto generated private key in the browser keystore?

We are trying to implement the following workflow: generate private key in browser, using window.crypto create a PKCS10 certificate signing request in the browser send the PKCS10 to a server the server signs the request and returns an x509…
Árpád Magosányi
  • 1,394
  • 2
  • 19
  • 35
1
vote
1 answer

what is the replacement or alternative for window.crypto.logout after firefox 33

previous day, we are using window.crypto.logout to clear the client mutual SSL authentication. After firefox 33, does anyone know how can we clear the client SSL authentication ? thank you
Biau
  • 13
  • 5
0
votes
1 answer

Javascript window.crypto.subtle library returns an uncaught error when trying to decrypt ciphertext using imported key

I am writing a script to decode a cipher text using a private key. The original text is Hello World. I used this website to generate the public private key pair, as well as testing the encryption:…
0
votes
1 answer

How to properly generate a random password with the window.crypto property?

The Math.floor(Math.random() * 100) or Math.ceil(Math.random() * 100) method of generating a random number isn't the most cryptographically secure. I want to use this method in a random Password application, I'm trying to use the window.crypto…
Millhorn
  • 2,953
  • 7
  • 39
  • 77
0
votes
1 answer

window.crypto.subtle not working in IIS hosted web application

I'm using window.crypto.subtle.importKey() for one of the authentication process in my app. Its working when i ran it on node server but its not working when i hosted it on IIS. Error: importKey of undefined (Till window.crypto i'm getting)
Akhil Naidu
  • 789
  • 1
  • 4
  • 16
1
2