https://github.com/scala-js/scala-js-java-securerandom
Implementation of java.security.SecureRandom for Scala.js in browsers and Node.js
https://github.com/scala-js/scala-js-java-securerandom
Last synced: 7 months ago
JSON representation
Implementation of java.security.SecureRandom for Scala.js in browsers and Node.js
- Host: GitHub
- URL: https://github.com/scala-js/scala-js-java-securerandom
- Owner: scala-js
- License: apache-2.0
- Created: 2022-03-30T07:55:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-06T22:59:53.000Z (over 2 years ago)
- Last Synced: 2024-03-27T01:12:52.078Z (over 1 year ago)
- Language: Scala
- Size: 21.5 KB
- Stars: 6
- Watchers: 5
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# scalajs-java-securerandom
`scalajs-java-securerandom` provides `java.security.SecureRandom` for Scala.js, in Node.js, in browsers, and in other environments that provide the Web Crypto API.
## Usage
Use the following dependency:
```scala
libraryDependencies += ("org.scala-js" %%% "scalajs-java-securerandom" % "1.0.0").cross(CrossVersion.for3Use2_13)
```
When using a `crossProject`, add the above in `.jsSettings(...)`.
You can then use `java.security.SecureRandom` from your code, and by extension, the `java.util.UUID.randomUUID()` method.
When running in an unsupported environment, a `java.lang.UnsupportedOperationException` will be thrown when trying to instantiate `java.security.SecureRandom`.
Supported environments are:
* Node.js,
* Browsers,
* Using [JSDOM](https://github.com/jsdom/jsdom) >= 20.0.0
* Other environments that provide `crypto.getRandomValues(typedArray)`, from the Web Crypto API.
## License
`scalajs-java-securerandom` is distributed under the [Apache 2.0 license](./LICENSE.txt), like Scala.js itself.