-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: format examples them according k6-docs ESLint
- Loading branch information
1 parent
b51964d
commit 4513adf
Showing
17 changed files
with
277 additions
and
289 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
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 |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import { crypto } from "k6/x/webcrypto"; | ||
|
||
export default async function () { | ||
const key = await crypto.subtle.generateKey( | ||
{ | ||
name: "AES-CBC", | ||
length: 256 | ||
}, | ||
true, | ||
[ | ||
"encrypt", | ||
"decrypt", | ||
] | ||
); | ||
const key = await crypto.subtle.generateKey( | ||
{ | ||
name: "AES-CBC", | ||
length: 256, | ||
}, | ||
true, | ||
["encrypt", "decrypt"] | ||
); | ||
|
||
console.log(JSON.stringify(key)) | ||
} | ||
console.log(JSON.stringify(key)); | ||
} |
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,17 +1,14 @@ | ||
import { crypto } from "k6/x/webcrypto"; | ||
|
||
export default async function () { | ||
const key = await crypto.subtle.generateKey( | ||
{ | ||
name: "ECDH", | ||
namedCurve: "P-256" | ||
}, | ||
true, | ||
[ | ||
"deriveKey", | ||
"deriveBits" | ||
] | ||
); | ||
const key = await crypto.subtle.generateKey( | ||
{ | ||
name: "ECDH", | ||
namedCurve: "P-256", | ||
}, | ||
true, | ||
["deriveKey", "deriveBits"] | ||
); | ||
|
||
console.log(JSON.stringify(key)) | ||
} | ||
console.log(JSON.stringify(key)); | ||
} |
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,14 +1,14 @@ | ||
import { crypto } from "k6/x/webcrypto"; | ||
|
||
export default async function () { | ||
const key = await crypto.subtle.generateKey( | ||
{ | ||
name: "ECDSA", | ||
namedCurve: "P-256" | ||
}, | ||
true, | ||
["sign", "verify"] | ||
); | ||
const key = await crypto.subtle.generateKey( | ||
{ | ||
name: "ECDSA", | ||
namedCurve: "P-256", | ||
}, | ||
true, | ||
["sign", "verify"] | ||
); | ||
|
||
console.log(JSON.stringify(key)) | ||
} | ||
console.log(JSON.stringify(key)); | ||
} |
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,21 +1,18 @@ | ||
import { crypto } from "k6/x/webcrypto"; | ||
|
||
export default async function () { | ||
try { | ||
const key = await crypto.subtle.generateKey( | ||
{ | ||
name: "HMAC", | ||
hash: { name: "SHA-512" }, | ||
length: 256, | ||
}, | ||
true, | ||
[ | ||
"sign", | ||
"verify", | ||
] | ||
); | ||
console.log(JSON.stringify(key)) | ||
} catch (e) { | ||
console.log(JSON.stringify(e)) | ||
} | ||
} | ||
try { | ||
const key = await crypto.subtle.generateKey( | ||
{ | ||
name: "HMAC", | ||
hash: { name: "SHA-512" }, | ||
length: 256, | ||
}, | ||
true, | ||
["sign", "verify"] | ||
); | ||
console.log(JSON.stringify(key)); | ||
} catch (e) { | ||
console.log(JSON.stringify(e)); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -27,4 +27,3 @@ const printArrayBuffer = (buffer) => { | |
let view = new Uint8Array(buffer); | ||
return Array.from(view); | ||
}; | ||
|
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,26 +1,24 @@ | ||
import { crypto } from "k6/x/webcrypto"; | ||
|
||
export default async function () { | ||
const generatedKey = await crypto.subtle.generateKey( | ||
{ | ||
name: "AES-CBC", | ||
length: "256" | ||
}, | ||
true, | ||
[ | ||
"encrypt", | ||
"decrypt", | ||
] | ||
); | ||
export default async function () { | ||
const generatedKey = await crypto.subtle.generateKey( | ||
{ | ||
name: "AES-CBC", | ||
length: "256", | ||
}, | ||
true, | ||
["encrypt", "decrypt"] | ||
); | ||
|
||
const exportedKey = await crypto.subtle.exportKey("raw", generatedKey); | ||
const exportedKey = await crypto.subtle.exportKey("raw", generatedKey); | ||
|
||
const importedKey = await crypto.subtle.importKey( | ||
"raw", | ||
exportedKey, | ||
"AES-CBC", | ||
true, ["encrypt", "decrypt"] | ||
); | ||
const importedKey = await crypto.subtle.importKey( | ||
"raw", | ||
exportedKey, | ||
"AES-CBC", | ||
true, | ||
["encrypt", "decrypt"] | ||
); | ||
|
||
console.log(JSON.stringify(importedKey)) | ||
} | ||
console.log(JSON.stringify(importedKey)); | ||
} |
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,31 +1,28 @@ | ||
import { crypto } from "k6/x/webcrypto"; | ||
|
||
export default async function () { | ||
try { | ||
const generatedKey = await crypto.subtle.generateKey( | ||
{ | ||
name: "HMAC", | ||
hash: { name: "SHA-256" }, | ||
}, | ||
true, | ||
[ | ||
"sign", | ||
"verify", | ||
] | ||
); | ||
export default async function () { | ||
try { | ||
const generatedKey = await crypto.subtle.generateKey( | ||
{ | ||
name: "HMAC", | ||
hash: { name: "SHA-256" }, | ||
}, | ||
true, | ||
["sign", "verify"] | ||
); | ||
|
||
const exportedKey = await crypto.subtle.exportKey("raw", generatedKey); | ||
const exportedKey = await crypto.subtle.exportKey("raw", generatedKey); | ||
|
||
const importedKey = await crypto.subtle.importKey( | ||
"raw", | ||
exportedKey, | ||
{ name: "HMAC", hash: { name: "SHA-256" } }, | ||
true, ["sign", "verify"] | ||
); | ||
const importedKey = await crypto.subtle.importKey( | ||
"raw", | ||
exportedKey, | ||
{ name: "HMAC", hash: { name: "SHA-256" } }, | ||
true, | ||
["sign", "verify"] | ||
); | ||
|
||
console.log(JSON.stringify(importedKey)) | ||
} catch (err) { | ||
console.log(JSON.stringify(err)); | ||
} | ||
|
||
} | ||
console.log(JSON.stringify(importedKey)); | ||
} catch (err) { | ||
console.log(JSON.stringify(err)); | ||
} | ||
} |
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,38 +1,36 @@ | ||
import { crypto } from "k6/x/webcrypto"; | ||
|
||
export default async function () { | ||
try { | ||
const generatedKey = await crypto.subtle.generateKey( | ||
{ | ||
name: "AES-CBC", | ||
length: "256" | ||
}, | ||
true, | ||
[ | ||
"encrypt", | ||
"decrypt", | ||
] | ||
); | ||
|
||
console.log("generated: " + JSON.stringify(generatedKey)); | ||
|
||
const exportedKey = await crypto.subtle.exportKey("jwk", generatedKey); | ||
|
||
console.log("exported: " + JSON.stringify(exportedKey)); | ||
|
||
const importedKey = await crypto.subtle.importKey( | ||
"jwk", | ||
exportedKey, | ||
"AES-CBC", | ||
true, ["encrypt", "decrypt"] | ||
); | ||
|
||
console.log("imported: " + JSON.stringify(importedKey)); | ||
|
||
const exportedAgain = await crypto.subtle.exportKey("jwk", importedKey); | ||
|
||
console.log("exported again: " + JSON.stringify(exportedAgain)); | ||
} catch (err) { | ||
console.log(JSON.stringify(err)); | ||
} | ||
} | ||
export default async function () { | ||
try { | ||
const generatedKey = await crypto.subtle.generateKey( | ||
{ | ||
name: "AES-CBC", | ||
length: "256", | ||
}, | ||
true, | ||
["encrypt", "decrypt"] | ||
); | ||
|
||
console.log("generated: " + JSON.stringify(generatedKey)); | ||
|
||
const exportedKey = await crypto.subtle.exportKey("jwk", generatedKey); | ||
|
||
console.log("exported: " + JSON.stringify(exportedKey)); | ||
|
||
const importedKey = await crypto.subtle.importKey( | ||
"jwk", | ||
exportedKey, | ||
"AES-CBC", | ||
true, | ||
["encrypt", "decrypt"] | ||
); | ||
|
||
console.log("imported: " + JSON.stringify(importedKey)); | ||
|
||
const exportedAgain = await crypto.subtle.exportKey("jwk", importedKey); | ||
|
||
console.log("exported again: " + JSON.stringify(exportedAgain)); | ||
} catch (err) { | ||
console.log(JSON.stringify(err)); | ||
} | ||
} |
Oops, something went wrong.