Megosztás a következőn keresztül:


CryptographyClient class

Az Azure Key Vault-kulcson vagy egy helyi JsonWebKeyvégzett titkosítási műveletekhez használt ügyfél.

Konstruktorok

CryptographyClient(JsonWebKey)

A titkosítási ügyfél új példányát hozza létre a megadott kulcshoz helyi módban.

Példahasználat:

import { CryptographyClient } from "@azure/keyvault-keys";

const jsonWebKey = {
  kty: "RSA",
  kid: "test-key-123",
  use: "sig",
  alg: "RS256",
  n: new Uint8Array([112, 34, 56, 98, 123, 244, 200, 99]),
  e: new Uint8Array([1, 0, 1]),
  d: new Uint8Array([45, 67, 89, 23, 144, 200, 76, 233]),
  p: new Uint8Array([34, 89, 100, 77, 204, 56, 29, 77]),
  q: new Uint8Array([78, 99, 201, 45, 188, 34, 67, 90]),
  dp: new Uint8Array([23, 45, 78, 56, 200, 144, 32, 67]),
  dq: new Uint8Array([12, 67, 89, 144, 99, 56, 23, 45]),
  qi: new Uint8Array([78, 90, 45, 201, 34, 67, 120, 55]),
};
const client = new CryptographyClient(jsonWebKey);
CryptographyClient(string | KeyVaultKey, TokenCredential, CryptographyClientOptions)

A titkosítási ügyfél új példányát hozza létre a megadott kulcshoz

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

// Create or retrieve a key from the keyvault
const myKey = await client.createKey("MyKey", "RSA");

// Lastly, create our cryptography client and connect to the service
const cryptographyClient = new CryptographyClient(myKey, credential);

Tulajdonságok

keyID

Az ügyfél titkosítási műveleteinek végrehajtásához használt kulcs azonosítója.

vaultUrl

A tároló alap URL-címe. Ha egy helyi JsonWebKey használ, a vaultUrl üres lesz.

Metódusok

decrypt(DecryptParameters, DecryptOptions)

A megadott titkosítási paraméterekkel visszafejti a megadott rejtjelszöveget. A visszafejtési paraméterekben használt algoritmustól függően a lehetséges visszafejtési paraméterek halmaza megváltozik.

A Microsoft azt javasolja, hogy ne használja a CBC-t anélkül, hogy először biztosítaná a rejtjelszöveg integritását például egy HMAC használatával. További információt a https://learn.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode talál.

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey.id, credential);

const encryptResult = await cryptographyClient.encrypt({
  algorithm: "RSA1_5",
  plaintext: Buffer.from("My Message"),
});
console.log("encrypt result: ", encryptResult.result);

const decryptResult = await cryptographyClient.decrypt({
  algorithm: "RSA1_5",
  ciphertext: encryptResult.result,
});
console.log("decrypt result: ", decryptResult.result.toString());
decrypt(string, Uint8Array, DecryptOptions)

A megadott titkosítószöveg visszafejtése a megadott titkosítási algoritmussal

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey.id, credential);

const encryptResult = await cryptographyClient.encrypt({
  algorithm: "RSA1_5",
  plaintext: Buffer.from("My Message"),
});
console.log("encrypt result: ", encryptResult.result);

const decryptResult = await cryptographyClient.decrypt({
  algorithm: "RSA1_5",
  ciphertext: encryptResult.result,
});
console.log("decrypt result: ", decryptResult.result.toString());

A Microsoft azt javasolja, hogy ne használja a CBC-t anélkül, hogy először biztosítaná a rejtjelszöveg integritását például egy HMAC használatával. További információt a https://learn.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode talál.

encrypt(EncryptParameters, EncryptOptions)

A megadott egyszerű szöveget a megadott titkosítási paraméterekkel titkosítja. A titkosítási paraméterekben beállított algoritmustól függően a lehetséges titkosítási paraméterek halmaza megváltozik.

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey.id, credential);

const encryptResult = await cryptographyClient.encrypt({
  algorithm: "RSA1_5",
  plaintext: Buffer.from("My Message"),
});
console.log("encrypt result: ", encryptResult.result);
encrypt(string, Uint8Array, EncryptOptions)

A megadott egyszerű szöveg titkosítása a megadott titkosítási algoritmussal

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey.id, credential);

const encryptResult = await cryptographyClient.encrypt({
  algorithm: "RSA1_5",
  plaintext: Buffer.from("My Message"),
});
console.log("encrypt result: ", encryptResult.result);
sign(string, Uint8Array, SignOptions)

Kriptográfiai aláírással egy üzenet kivonata

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
import { createHash } from "node:crypto";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

let myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const signatureValue = "MySignature";
const hash = createHash("sha256");

const digest = hash.update(signatureValue).digest();
console.log("digest: ", digest);

const signResult = await cryptographyClient.sign("RS256", digest);
console.log("sign result: ", signResult.result);
signData(string, Uint8Array, SignOptions)

Kriptográfiai aláírással egy adatblokk

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const signResult = await cryptographyClient.signData("RS256", Buffer.from("My Message"));
console.log("sign result: ", signResult.result);
unwrapKey(KeyWrapAlgorithm, Uint8Array, UnwrapKeyOptions)

A megadott burkolt kulcs feloldása a megadott titkosítási algoritmussal

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const wrapResult = await cryptographyClient.wrapKey("RSA-OAEP", Buffer.from("My Key"));
console.log("wrap result:", wrapResult.result);

const unwrapResult = await cryptographyClient.unwrapKey("RSA-OAEP", wrapResult.result);
console.log("unwrap result: ", unwrapResult.result);
verify(string, Uint8Array, Uint8Array, VerifyOptions)

Az aláírt üzenet kivonatának ellenőrzése

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
import { createHash } from "node:crypto";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const hash = createHash("sha256");
hash.update("My Message");
const digest = hash.digest();

const signResult = await cryptographyClient.sign("RS256", digest);
console.log("sign result: ", signResult.result);

const verifyResult = await cryptographyClient.verify("RS256", digest, signResult.result);
console.log("verify result: ", verifyResult.result);
verifyData(string, Uint8Array, Uint8Array, VerifyOptions)

Az aláírt adatblokk ellenőrzése

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const buffer = Buffer.from("My Message");

const signResult = await cryptographyClient.signData("RS256", buffer);
console.log("sign result: ", signResult.result);

const verifyResult = await cryptographyClient.verifyData("RS256", buffer, signResult.result);
console.log("verify result: ", verifyResult.result);
wrapKey(KeyWrapAlgorithm, Uint8Array, WrapKeyOptions)

A megadott kulcs körbefuttatása a megadott titkosítási algoritmussal

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const wrapResult = await cryptographyClient.wrapKey("RSA-OAEP", Buffer.from("My Key"));
console.log("wrap result:", wrapResult.result);

Konstruktor adatai

CryptographyClient(JsonWebKey)

A titkosítási ügyfél új példányát hozza létre a megadott kulcshoz helyi módban.

Példahasználat:

import { CryptographyClient } from "@azure/keyvault-keys";

const jsonWebKey = {
  kty: "RSA",
  kid: "test-key-123",
  use: "sig",
  alg: "RS256",
  n: new Uint8Array([112, 34, 56, 98, 123, 244, 200, 99]),
  e: new Uint8Array([1, 0, 1]),
  d: new Uint8Array([45, 67, 89, 23, 144, 200, 76, 233]),
  p: new Uint8Array([34, 89, 100, 77, 204, 56, 29, 77]),
  q: new Uint8Array([78, 99, 201, 45, 188, 34, 67, 90]),
  dp: new Uint8Array([23, 45, 78, 56, 200, 144, 32, 67]),
  dq: new Uint8Array([12, 67, 89, 144, 99, 56, 23, 45]),
  qi: new Uint8Array([78, 90, 45, 201, 34, 67, 120, 55]),
};
const client = new CryptographyClient(jsonWebKey);
new CryptographyClient(key: JsonWebKey)

Paraméterek

key
JsonWebKey

A titkosítási műveletek során használni kívánt JsonWebKey.

CryptographyClient(string | KeyVaultKey, TokenCredential, CryptographyClientOptions)

A titkosítási ügyfél új példányát hozza létre a megadott kulcshoz

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

// Create or retrieve a key from the keyvault
const myKey = await client.createKey("MyKey", "RSA");

// Lastly, create our cryptography client and connect to the service
const cryptographyClient = new CryptographyClient(myKey, credential);
new CryptographyClient(key: string | KeyVaultKey, credential: TokenCredential, pipelineOptions?: CryptographyClientOptions)

Paraméterek

key

string | KeyVaultKey

A titkosítási feladatokhoz használandó kulcs. Itt is átadhatja a kulcs azonosítóját, azaz az URL-címét.

credential
TokenCredential

Egy objektum, amely implementálja a szolgáltatáshoz érkező kérések hitelesítéséhez használt TokenCredential felületet. Az @azure/identity csomag használatával hozzon létre egy, az igényeinek megfelelő hitelesítő adatokat.

pipelineOptions
CryptographyClientOptions

A Key Vault API-kérések konfigurálásához használt folyamatbeállítások. Hagyja ki ezt a paramétert az alapértelmezett folyamatkonfiguráció használatához.

Tulajdonság adatai

keyID

Az ügyfél titkosítási műveleteinek végrehajtásához használt kulcs azonosítója.

undefined | string keyID

Tulajdonság értéke

undefined | string

vaultUrl

A tároló alap URL-címe. Ha egy helyi JsonWebKey használ, a vaultUrl üres lesz.

string vaultUrl

Tulajdonság értéke

string

Metódus adatai

decrypt(DecryptParameters, DecryptOptions)

A megadott titkosítási paraméterekkel visszafejti a megadott rejtjelszöveget. A visszafejtési paraméterekben használt algoritmustól függően a lehetséges visszafejtési paraméterek halmaza megváltozik.

A Microsoft azt javasolja, hogy ne használja a CBC-t anélkül, hogy először biztosítaná a rejtjelszöveg integritását például egy HMAC használatával. További információt a https://learn.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode talál.

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey.id, credential);

const encryptResult = await cryptographyClient.encrypt({
  algorithm: "RSA1_5",
  plaintext: Buffer.from("My Message"),
});
console.log("encrypt result: ", encryptResult.result);

const decryptResult = await cryptographyClient.decrypt({
  algorithm: "RSA1_5",
  ciphertext: encryptResult.result,
});
console.log("decrypt result: ", decryptResult.result.toString());
function decrypt(decryptParameters: DecryptParameters, options?: DecryptOptions): Promise<DecryptResult>

Paraméterek

decryptParameters
DecryptParameters

A visszafejtési paraméterek.

options
DecryptOptions

További lehetőségek.

Válaszok

Promise<DecryptResult>

decrypt(string, Uint8Array, DecryptOptions)

Figyelmeztetés

Ez az API már elavult.

Use decrypt({ algorithm, ciphertext }, options) instead.

A megadott titkosítószöveg visszafejtése a megadott titkosítási algoritmussal

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey.id, credential);

const encryptResult = await cryptographyClient.encrypt({
  algorithm: "RSA1_5",
  plaintext: Buffer.from("My Message"),
});
console.log("encrypt result: ", encryptResult.result);

const decryptResult = await cryptographyClient.decrypt({
  algorithm: "RSA1_5",
  ciphertext: encryptResult.result,
});
console.log("decrypt result: ", decryptResult.result.toString());

A Microsoft azt javasolja, hogy ne használja a CBC-t anélkül, hogy először biztosítaná a rejtjelszöveg integritását például egy HMAC használatával. További információt a https://learn.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode talál.

function decrypt(algorithm: string, ciphertext: Uint8Array, options?: DecryptOptions): Promise<DecryptResult>

Paraméterek

algorithm

string

A használni kívánt algoritmus.

ciphertext

Uint8Array

A visszafejtendő szöveg.

options
DecryptOptions

További lehetőségek.

Válaszok

Promise<DecryptResult>

encrypt(EncryptParameters, EncryptOptions)

A megadott egyszerű szöveget a megadott titkosítási paraméterekkel titkosítja. A titkosítási paraméterekben beállított algoritmustól függően a lehetséges titkosítási paraméterek halmaza megváltozik.

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey.id, credential);

const encryptResult = await cryptographyClient.encrypt({
  algorithm: "RSA1_5",
  plaintext: Buffer.from("My Message"),
});
console.log("encrypt result: ", encryptResult.result);
function encrypt(encryptParameters: EncryptParameters, options?: EncryptOptions): Promise<EncryptResult>

Paraméterek

encryptParameters
EncryptParameters

A választott titkosítási algoritmuson kulcsolt titkosítási paraméterek.

options
EncryptOptions

További lehetőségek.

Válaszok

Promise<EncryptResult>

encrypt(string, Uint8Array, EncryptOptions)

Figyelmeztetés

Ez az API már elavult.

Use encrypt({ algorithm, plaintext }, options) instead.

A megadott egyszerű szöveg titkosítása a megadott titkosítási algoritmussal

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey.id, credential);

const encryptResult = await cryptographyClient.encrypt({
  algorithm: "RSA1_5",
  plaintext: Buffer.from("My Message"),
});
console.log("encrypt result: ", encryptResult.result);
function encrypt(algorithm: string, plaintext: Uint8Array, options?: EncryptOptions): Promise<EncryptResult>

Paraméterek

algorithm

string

A használni kívánt algoritmus.

plaintext

Uint8Array

A titkosítandó szöveg.

options
EncryptOptions

További lehetőségek.

Válaszok

Promise<EncryptResult>

sign(string, Uint8Array, SignOptions)

Kriptográfiai aláírással egy üzenet kivonata

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
import { createHash } from "node:crypto";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

let myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const signatureValue = "MySignature";
const hash = createHash("sha256");

const digest = hash.update(signatureValue).digest();
console.log("digest: ", digest);

const signResult = await cryptographyClient.sign("RS256", digest);
console.log("sign result: ", signResult.result);
function sign(algorithm: string, digest: Uint8Array, options?: SignOptions): Promise<SignResult>

Paraméterek

algorithm

string

A használni kívánt aláíró algoritmus.

digest

Uint8Array

Az aláírandó adatok kivonata.

options
SignOptions

További lehetőségek.

Válaszok

Promise<SignResult>

signData(string, Uint8Array, SignOptions)

Kriptográfiai aláírással egy adatblokk

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const signResult = await cryptographyClient.signData("RS256", Buffer.from("My Message"));
console.log("sign result: ", signResult.result);
function signData(algorithm: string, data: Uint8Array, options?: SignOptions): Promise<SignResult>

Paraméterek

algorithm

string

A használni kívánt aláíró algoritmus.

data

Uint8Array

Az aláírandó adatok.

options
SignOptions

További lehetőségek.

Válaszok

Promise<SignResult>

unwrapKey(KeyWrapAlgorithm, Uint8Array, UnwrapKeyOptions)

A megadott burkolt kulcs feloldása a megadott titkosítási algoritmussal

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const wrapResult = await cryptographyClient.wrapKey("RSA-OAEP", Buffer.from("My Key"));
console.log("wrap result:", wrapResult.result);

const unwrapResult = await cryptographyClient.unwrapKey("RSA-OAEP", wrapResult.result);
console.log("unwrap result: ", unwrapResult.result);
function unwrapKey(algorithm: KeyWrapAlgorithm, encryptedKey: Uint8Array, options?: UnwrapKeyOptions): Promise<UnwrapResult>

Paraméterek

algorithm
KeyWrapAlgorithm

A kulcs kibontásához használt visszafejtési algoritmus.

encryptedKey

Uint8Array

A feloldandó titkosított kulcs.

options
UnwrapKeyOptions

További lehetőségek.

Válaszok

Promise<UnwrapResult>

verify(string, Uint8Array, Uint8Array, VerifyOptions)

Az aláírt üzenet kivonatának ellenőrzése

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
import { createHash } from "node:crypto";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const hash = createHash("sha256");
hash.update("My Message");
const digest = hash.digest();

const signResult = await cryptographyClient.sign("RS256", digest);
console.log("sign result: ", signResult.result);

const verifyResult = await cryptographyClient.verify("RS256", digest, signResult.result);
console.log("verify result: ", verifyResult.result);
function verify(algorithm: string, digest: Uint8Array, signature: Uint8Array, options?: VerifyOptions): Promise<VerifyResult>

Paraméterek

algorithm

string

Az aláírási algoritmus, amellyel ellenőrizni lehet.

digest

Uint8Array

Az ellenőrizni kívánt kivonat.

signature

Uint8Array

Az aláírás, amellyel ellenőrizheti a kivonatot.

options
VerifyOptions

További lehetőségek.

Válaszok

Promise<VerifyResult>

verifyData(string, Uint8Array, Uint8Array, VerifyOptions)

Az aláírt adatblokk ellenőrzése

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const buffer = Buffer.from("My Message");

const signResult = await cryptographyClient.signData("RS256", buffer);
console.log("sign result: ", signResult.result);

const verifyResult = await cryptographyClient.verifyData("RS256", buffer, signResult.result);
console.log("verify result: ", verifyResult.result);
function verifyData(algorithm: string, data: Uint8Array, signature: Uint8Array, options?: VerifyOptions): Promise<VerifyResult>

Paraméterek

algorithm

string

A hitelesítéshez használt algoritmus.

data

Uint8Array

Az ellenőrizendő aláírt adatblokk.

signature

Uint8Array

Az aláírás, amellyel ellenőrizheti a blokkot.

options
VerifyOptions

További lehetőségek.

Válaszok

Promise<VerifyResult>

wrapKey(KeyWrapAlgorithm, Uint8Array, WrapKeyOptions)

A megadott kulcs körbefuttatása a megadott titkosítási algoritmussal

Példahasználat:

import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";

const credential = new DefaultAzureCredential();

const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;

const client = new KeyClient(url, credential);

const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);

const wrapResult = await cryptographyClient.wrapKey("RSA-OAEP", Buffer.from("My Key"));
console.log("wrap result:", wrapResult.result);
function wrapKey(algorithm: KeyWrapAlgorithm, key: Uint8Array, options?: WrapKeyOptions): Promise<WrapResult>

Paraméterek

algorithm
KeyWrapAlgorithm

A megadott kulcs körbefuttatásához használt titkosítási algoritmus.

key

Uint8Array

A tördelendő kulcs.

options
WrapKeyOptions

További lehetőségek.

Válaszok

Promise<WrapResult>