Skip to content

Commit e484686

Browse files
authored
Merge pull request #57 from tryandromeda/main
merge
2 parents 8fc9ae1 + a7379fb commit e484686

File tree

11 files changed

+1001
-12
lines changed

11 files changed

+1001
-12
lines changed

Cargo.lock

Lines changed: 98 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ version = "0.1.0"
1212

1313
[workspace.dependencies]
1414
andromeda-core = { path = "core" }
15-
andromeda-runtime = { path = "runtime" }
15+
andromeda-runtime = { path = "runtime" , features = ["canvas", "crypto"] }
1616
anyhow = "1.0.98"
1717
anymap = "0.12.1"
1818
base64-simd = "0.8.0"
@@ -35,6 +35,8 @@ reedline = "0.40.0"
3535
serde = { version = "1.0.130", features = ["derive"] }
3636
tokio = { version = "1.45.1", features = ["rt", "sync", "time"] }
3737
url = { version = "2", features = ["serde", "expose_internals"] }
38+
ring = "0.17.8"
39+
rand = "0.9.1"
3840

3941
[profile.release]
4042
lto = true

examples/crypto.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const uuid = crypto.randomUUID();
2+
console.log("Generated UUID:", uuid);
3+
console.log("UUID length:", uuid.length);
4+
console.log(
5+
"UUID has dashes at correct positions:",
6+
uuid.charAt(8) === "-" && uuid.charAt(13) === "-" &&
7+
uuid.charAt(18) === "-" && uuid.charAt(23) === "-",
8+
);
9+
10+
// Test getRandomValues
11+
console.log("\nTesting getRandomValues...");
12+
const buffer = new Uint8Array(16);
13+
const result = crypto.getRandomValues(buffer);
14+
console.log("Buffer filled:", buffer);
15+
console.log("Returned same array:", result === buffer);
16+
console.log("Buffer has non-zero values:", buffer.some((x) => x !== 0)); // Test digest
17+
console.log("\nTesting crypto.subtle.digest...");
18+
// Since TextEncoder is not available, we'll create a Uint8Array manually
19+
const testData = new Uint8Array([
20+
72,
21+
101,
22+
108,
23+
108,
24+
111,
25+
44,
26+
32,
27+
87,
28+
111,
29+
114,
30+
108,
31+
100,
32+
33,
33+
]); // "Hello, World!" as bytes
34+
crypto.subtle.digest("SHA-256", testData).then((hash) => {
35+
console.log("SHA-256 hash:", hash);
36+
console.log("Hash type:", typeof hash);
37+
}).catch((err) => {
38+
console.error("Digest error:", err);
39+
});
40+
41+
// Test generateKey
42+
console.log("\nTesting crypto.subtle.generateKey...");
43+
crypto.subtle.generateKey("AES-GCM", true, ["encrypt", "decrypt"]).then(
44+
(key) => {
45+
console.log("Generated key:", key);
46+
console.log("Key type:", typeof key);
47+
},
48+
).catch((err) => {
49+
console.error("GenerateKey error:", err);
50+
});

runtime/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ readme = "../README.md"
99
[features]
1010
default = []
1111
canvas = ["dep:wgpu", "dep:image"]
12+
crypto = ["dep:ring", "dep:rand"]
1213

1314
[dependencies]
1415
andromeda-core.workspace = true
@@ -23,3 +24,5 @@ url.workspace = true
2324
base64-simd.workspace = true
2425
wgpu = { workspace = true, optional = true }
2526
image = { workspace = true, optional = true }
27+
ring = { workspace = true, optional = true }
28+
rand = { workspace = true, optional = true }

0 commit comments

Comments
 (0)