-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
209 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "randomx"] | ||
path = randomx | ||
url = https://github.com/tevador/RandomX.git | ||
url = https://github.com/tevador/RandomX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.xdag.crypto.randomx; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import com.google.common.collect.Lists; | ||
import com.google.common.io.BaseEncoding; | ||
|
||
public class Example { | ||
|
||
public static void main(String[] args) { | ||
String key = "hello xdagj-native-randomx"; | ||
byte[] keyBytes = key.getBytes(StandardCharsets.UTF_8); | ||
|
||
// 1. build randomx jna wrapper | ||
RandomXWrapper randomXWrapper = RandomXWrapper.builder() | ||
.flags(Lists.newArrayList(RandomXWrapper.Flag.JIT)) | ||
.fastInit(true) | ||
.build(); | ||
|
||
// 2. init dataset or cache | ||
randomXWrapper.init(keyBytes); | ||
|
||
// 3. create randomxVm | ||
RandomXVM randomxVm = randomXWrapper.createVM(); | ||
|
||
// 4. calculate hash | ||
byte[] hash = randomxVm.getHash(keyBytes); | ||
|
||
// 5. print result | ||
System.out.println("message:" + key); | ||
System.out.println("hash:" + BaseEncoding.base16().lowerCase().encode(hash)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.