Class Crypto
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The Crypto interface represents basic cryptography features available in the current context.
It allows access to a cryptographically strong random number generator and to cryptographic primitives.
[Value("Crypto")]
public class Crypto
- Inheritance
-
Crypto
- Inherited Members
Remarks
The Crypto is available in windows using the Window.Crypto property and in workers using the WorkerGlobalScope.Crypto property.
-Web security
-Secure contexts
-Features restricted to secure contexts
-Transport Layer Security
-Strict-Transport-Security
Constructors
Crypto()
public Crypto()
Properties
Subtle
The Crypto.subtle read-only property returns a
SubtleCrypto which can then be used to perform low-level
cryptographic operations.
[Value("subtle")]
public SubtleCrypto Subtle { get; }
Property Value
- SubtleCrypto
A SubtleCrypto object you can use to interact with the Web Crypto API's
low-level cryptography features.
Remarks
Methods
GetRandomValues(Union223)
The Crypto.getRandomValues() method lets you get cryptographically strong random values.
The array given as the parameter is filled with random numbers (random in its cryptographic meaning).
[Value("getRandomValues")]
public Union223 GetRandomValues(Union223 array)
Parameters
arrayUnion223
Returns
- Union223
The same array passed as
typedArraybut with its contents replaced with the newly generated random numbers.
Note thattypedArrayis modified in-place, and no copy is made.
Remarks
To guarantee enough performance, implementations are not using a truly random number generator, but they are using a pseudo-random number generator seeded with a value with enough entropy.
The pseudo-random number generator algorithm (PRNG) may vary across user agent, but is suitable for cryptographic purposes.
getRandomValues() is the only member of the Crypto interface which can be used from an insecure context.
-Web Crypto API
-MathRandom, a non-cryptographic source of random numbers.
RandomUUID()
The randomUUID() method of the Crypto interface is used to generate a v4 {{Glossary("UUID")}} using a cryptographically secure random number generator.
[Value("randomUUID")]
public string RandomUUID()
Returns
- string
A string containing a randomly generated, 36 character long v4 UUID.
Remarks
-Web Crypto API
-GetRandomValues(Union223), a source for arbitrary amounts of secure random bytes.