

Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh [SDK AWS Doc](https://github.com/awsdocs/aws-doc-sdk-examples). GitHub 

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# AWS Payment Cryptography Contoh Data Plane menggunakan AWS CLI
<a name="cli_2_payment-cryptography-data_code_examples"></a>

Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan AWS Command Line Interface With AWS Payment Cryptography Data Plane.

*Tindakan* merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

**Topics**
+ [Tindakan](#actions)

## Tindakan
<a name="actions"></a>

### `decrypt-data`
<a name="payment-cryptography-data_DecryptData_cli_2_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`decrypt-data`.

**AWS CLI**  
**Untuk mendekripsi ciphertext**  
`decrypt-data`Contoh berikut mendekripsi data ciphertext menggunakan kunci simetris. Untuk operasi ini, kunci harus `KeyModesOfUse` disetel ke `Decrypt` dan `KeyUsage` disetel ke`TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY`.  

```
aws payment-cryptography-data decrypt-data \
    --key-identifier arn:aws:payment-cryptography:us-east-2:123456789012:key/kwapwa6qaifllw2h \
    --cipher-text 33612AB9D6929C3A828EB6030082B2BD \
    --decryption-attributes 'Symmetric={Mode=CBC}'
```
Output:  

```
{
    "KeyArn": "arn:aws:payment-cryptography:us-east-2:123456789012:key/kwapwa6qaifllw2h",
    "KeyCheckValue": "71D7AE",
    "PlainText": "31323334313233343132333431323334"
}
```
Untuk informasi selengkapnya, lihat [Mendekripsi data di Panduan](https://docs.aws.amazon.com/payment-cryptography/latest/userguide/decrypt-data.html) Pengguna *Kriptografi AWS Pembayaran*.  
+  Untuk detail API, lihat [DecryptData](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/payment-cryptography-data/decrypt-data.html)di *Referensi AWS CLI Perintah*. 

### `encrypt-data`
<a name="payment-cryptography-data_EncryptData_cli_2_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`encrypt-data`.

**AWS CLI**  
**Untuk mengenkripsi data**  
`encrypt-data`Contoh berikut mengenkripsi data plaintext menggunakan kunci simetris. Untuk operasi ini, kunci harus `KeyModesOfUse` disetel ke `Encrypt` dan `KeyUsage` disetel ke`TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY`.  

```
aws payment-cryptography-data encrypt-data \
    --key-identifier arn:aws:payment-cryptography:us-east-2:123456789012:key/kwapwa6qaifllw2h \
    --plain-text 31323334313233343132333431323334 \
    --encryption-attributes 'Symmetric={Mode=CBC}'
```
Output:  

```
{
    "KeyArn": "arn:aws:payment-cryptography:us-east-2:123456789012:key/kwapwa6qaifllw2h",
    "KeyCheckValue": "71D7AE",
    "CipherText": "33612AB9D6929C3A828EB6030082B2BD"
}
```
Untuk informasi selengkapnya, lihat [Mengenkripsi data](https://docs.aws.amazon.com/payment-cryptography/latest/userguide/encrypt-data.html) di *Panduan Pengguna Kriptografi AWS Pembayaran*.  
+  Untuk detail API, lihat [EncryptData](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/payment-cryptography-data/encrypt-data.html)di *Referensi AWS CLI Perintah*. 

### `generate-card-validation-data`
<a name="payment-cryptography-data_GenerateCardValidationData_cli_2_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`generate-card-validation-data`.

**AWS CLI**  
**Untuk menghasilkan CVV**  
`generate-card-validation-data`Contoh berikut menghasilkan CVV/CVV2.  

```
aws payment-cryptography-data generate-card-validation-data \
    --key-identifier arn:aws:payment-cryptography:us-east-2:123456789012:key/kwapwa6qaifllw2h \
    --primary-account-number=171234567890123 \
    --generation-attributes CardVerificationValue2={CardExpiryDate=0123}
```
Output:  

```
{
    "KeyArn": "arn:aws:payment-cryptography:us-east-2:123456789012:key/kwapwa6qaifllw2h",
    "KeyCheckValue": "CADDA1",
    "ValidationData": "801"
}
```
Untuk informasi selengkapnya, lihat [Menghasilkan data kartu](https://docs.aws.amazon.com/payment-cryptography/latest/userguide/generate-card-data.html) di *Panduan Pengguna Kriptografi AWS Pembayaran*.  
+  Untuk detail API, lihat [GenerateCardValidationData](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/payment-cryptography-data/generate-card-validation-data.html)di *Referensi AWS CLI Perintah*. 

### `generate-mac`
<a name="payment-cryptography-data_GenerateMac_cli_2_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`generate-mac`.

**AWS CLI**  
**Untuk menghasilkan MAC**  
`generate-card-validation-data`Contoh berikut menghasilkan Hash Based Message Authentication Code (HMAC) untuk otentikasi data kartu menggunakan algoritma HMAC\$1 dan kunci enkripsi HMACSHA256 . Kuncinya harus `KeyUsage` disetel ke `TR31_M7_HMAC_KEY` dan `KeyModesOfUse` ke`Generate`.  

```
aws payment-cryptography-data generate-mac \
    --key-identifier arn:aws:payment-cryptography:us-east-2:123456789012:key/kwapwa6qaifllw2h \
    --message-data "3b313038383439303031303733393431353d32343038323236303030373030303f33" \
    --generation-attributes Algorithm=HMAC_SHA256
```
Output:  

```
{
    "KeyArn": "arn:aws:payment-cryptography:us-east-2:123456789012:key/kwapwa6qaifllw2h,
    "KeyCheckValue": "2976E7",
    "Mac": "ED87F26E961C6D0DDB78DA5038AA2BDDEA0DCE03E5B5E96BDDD494F4A7AA470C"
}
```
Untuk informasi selengkapnya, lihat [Menghasilkan MAC](https://docs.aws.amazon.com/payment-cryptography/latest/userguide/generate-mac.html) di *Panduan Pengguna Kriptografi AWS Pembayaran*.  
+  Untuk detail API, lihat [GenerateMac](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/payment-cryptography-data/generate-mac.html)di *Referensi AWS CLI Perintah*. 

### `generate-pin-data`
<a name="payment-cryptography-data_GeneratePinData_cli_2_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`generate-pin-data`.

**AWS CLI**  
**Untuk menghasilkan PIN**  
`generate-card-validation-data`Contoh berikut menghasilkan PIN acak baru menggunakan skema PIN Visa.  

```
aws payment-cryptography-data generate-pin-data \
    --generation-key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/37y2tsl45p5zjbh2 \
    --encryption-key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/ivi5ksfsuplneuyt \
    --primary-account-number 171234567890123 \
    --pin-block-format ISO_FORMAT_0 \
    --generation-attributes VisaPin={PinVerificationKeyIndex=1}
```
Output:  

```
{
    "GenerationKeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/37y2tsl45p5zjbh2",
    "GenerationKeyCheckValue": "7F2363",
    "EncryptionKeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/ivi5ksfsuplneuyt",
    "EncryptionKeyCheckValue": "7CC9E2",
    "EncryptedPinBlock": "AC17DC148BDA645E",
    "PinData": {
        "VerificationValue": "5507"
    }
}
```
Untuk informasi selengkapnya, lihat [Menghasilkan data PIN](https://docs.aws.amazon.com/payment-cryptography/latest/userguide/generate-pin-data.html) di *Panduan Pengguna Kriptografi AWS Pembayaran*.  
+  Untuk detail API, lihat [GeneratePinData](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/payment-cryptography-data/generate-pin-data.html)di *Referensi AWS CLI Perintah*. 

### `re-encrypt-data`
<a name="payment-cryptography-data_ReEncryptData_cli_2_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`re-encrypt-data`.

**AWS CLI**  
**Untuk mengenkripsi ulang data dengan kunci yang berbeda**  
`re-encrypt-data`Contoh berikut mendekripsi teks sandi yang dienkripsi menggunakan kunci simetris AES dan mengenkripsi ulang menggunakan kunci Derived Unique Key Per Transaction (DUKPT).  

```
aws payment-cryptography-data re-encrypt-data \
    --incoming-key-identifier arn:aws:payment-cryptography:us-west-2:111122223333:key/hyvv7ymboitd4vfy \
    --outgoing-key-identifier arn:aws:payment-cryptography:us-west-2:111122223333:key/jl6ythkcvzesbxen \
    --cipher-text 4D2B0BDBA192D5AEFEAA5B3EC28E4A65383C313FFA25140101560F75FE1B99F27192A90980AB9334 \
    --incoming-encryption-attributes "Dukpt={Mode=ECB,KeySerialNumber=0123456789111111}" \
    --outgoing-encryption-attributes '{"Symmetric": {"Mode": "ECB"}}'
```
Output:  

```
{
    "CipherText": "F94959DA30EEFF0C035483C6067667CF6796E3C1AD28C2B61F9CFEB772A8DD41C0D6822931E0D3B1",
    "KeyArn": "arn:aws:payment-cryptography:us-west-2:111122223333:key/jl6ythkcvzesbxen",
    "KeyCheckValue": "2E8CD9"
}
```
Untuk informasi selengkapnya, lihat [Mengenkripsi dan mendekripsi data](https://docs.aws.amazon.com/payment-cryptography/latest/userguide/crypto-ops.encryptdecrypt.html) di Panduan Pengguna *Kriptografi AWS Pembayaran*.  
+  Untuk detail API, lihat [ReEncryptData](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/payment-cryptography-data/re-encrypt-data.html)di *Referensi AWS CLI Perintah*. 

### `translate-pin-data`
<a name="payment-cryptography-data_TranslatePinData_cli_2_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`translate-pin-data`.

**AWS CLI**  
**Untuk menerjemahkan data PIN**  
`translate-pin-data`Contoh berikut menerjemahkan PIN dari enkripsi PEK TDES menggunakan blok PIN ISO 0 ke Blok PIN AES ISO 4 menggunakan algoritma DUKPT.  

```
aws payment-cryptography-data translate-pin-data \
    --encrypted-pin-block "AC17DC148BDA645E" \
    --incoming-translation-attributes=IsoFormat0='{PrimaryAccountNumber=171234567890123}' \
    --incoming-key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/ivi5ksfsuplneuyt \
    --outgoing-key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/4pmyquwjs3yj4vwe \
    --outgoing-translation-attributes IsoFormat4="{PrimaryAccountNumber=171234567890123}" \
    --outgoing-dukpt-attributes KeySerialNumber="FFFF9876543210E00008"
```
Output:  

```
{
    "PinBlock": "1F4209C670E49F83E75CC72E81B787D9",
    "KeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/ivi5ksfsuplneuyt
    "KeyCheckValue": "7CC9E2"
}
```
Untuk informasi selengkapnya, lihat [Terjemahkan data PIN](https://docs.aws.amazon.com/payment-cryptography/latest/userguide/translate-pin-data.html) di *Panduan Pengguna Kriptografi AWS Pembayaran*.  
+  Untuk detail API, lihat [TranslatePinData](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/payment-cryptography-data/translate-pin-data.html)di *Referensi AWS CLI Perintah*. 

### `verify-auth-request-cryptogram`
<a name="payment-cryptography-data_VerifyAuthRequestCryptogram_cli_2_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`verify-auth-request-cryptogram`.

**AWS CLI**  
**Untuk memverifikasi permintaan autentikasi**  
`verify-auth-request-cryptogram`Contoh berikut memverifikasi Cryptogram Permintaan Otorisasi (ARQC).  

```
aws payment-cryptography-data verify-auth-request-cryptogram \
    --auth-request-cryptogram F6E1BD1E6037FB3E \
    --auth-response-attributes '{"ArpcMethod1": {"AuthResponseCode": "1111"}}' \
    --key-identifier arn:aws:payment-cryptography:us-west-2:111122223333:key/pboipdfzd4mdklya \
    --major-key-derivation-mode "EMV_OPTION_A" \
    --session-key-derivation-attributes '{"EmvCommon": {"ApplicationTransactionCounter": "1234","PanSequenceNumber": "01","PrimaryAccountNumber": "471234567890123"}}' \
    --transaction-data "123456789ABCDEF"
```
Output:  

```
{
    "AuthResponseValue": "D899B8C6FBF971AA",
    "KeyArn": "arn:aws:payment-cryptography:us-west-2:111122223333:key/pboipdfzd4mdklya",
    "KeyCheckValue": "985792"
}
```
Untuk informasi selengkapnya, lihat [kriptogram Verifikasi permintaan auth (ARQC) di Panduan Pengguna Kriptografi AWS](https://docs.aws.amazon.com/payment-cryptography/latest/userguide/data-operations.verifyauthrequestcryptogram.html) *Pembayaran*.  
+  Untuk detail API, lihat [VerifyAuthRequestCryptogram](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/payment-cryptography-data/verify-auth-request-cryptogram.html)di *Referensi AWS CLI Perintah*. 

### `verify-card-validation-data`
<a name="payment-cryptography-data_VerifyCardValidationData_cli_2_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`verify-card-validation-data`.

**AWS CLI**  
**Untuk memvalidasi CVV**  
`verify-card-validation-data`Contoh berikut memvalidasi CVV/ CVV2 untuk PAN.  

```
aws payment-cryptography-data verify-card-validation-data \
    --key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/tqv5yij6wtxx64pi \
    --primary-account-number=171234567890123 \
    --verification-attributes CardVerificationValue2={CardExpiryDate=0123} \
    --validation-data 801
```
Output:  

```
{
    "KeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/tqv5yij6wtxx64pi",
    "KeyCheckValue": "CADDA1"
}
```
Untuk informasi selengkapnya, lihat [Verifikasi data kartu](https://docs.aws.amazon.com/payment-cryptography/latest/userguide/verify-card-data.html) di *Panduan Pengguna Kriptografi AWS Pembayaran*.  
+  Untuk detail API, lihat [VerifyCardValidationData](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/payment-cryptography-data/verify-card-validation-data.html)di *Referensi AWS CLI Perintah*. 

### `verify-mac`
<a name="payment-cryptography-data_VerifyMac_cli_2_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`verify-mac`.

**AWS CLI**  
**Untuk memverifikasi MAC**  
`verify-mac`Contoh berikut memverifikasi Hash Based Message Authentication Code (HMAC) untuk otentikasi data kartu menggunakan algoritma HMAC\$1 dan kunci enkripsi HMACSHA256 .  

```
aws payment-cryptography-data verify-mac \
    --key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/qnobl5lghrzunce6 \
    --message-data "3b343038383439303031303733393431353d32343038323236303030373030303f33" \
    --verification-attributes='Algorithm=HMAC_SHA256' \
    --mac ED87F26E961C6D0DDB78DA5038AA2BDDEA0DCE03E5B5E96BDDD494F4A7AA470C
```
Output:  

```
{
    "KeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/qnobl5lghrzunce6,
    "KeyCheckValue": "2976E7",
}
```
Untuk informasi selengkapnya, lihat [Verifikasi MAC](https://docs.aws.amazon.com/payment-cryptography/latest/userguide/verify-mac.html) di *Panduan Pengguna Kriptografi AWS Pembayaran*.  
+  Untuk detail API, lihat [VerifyMac](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/payment-cryptography-data/verify-mac.html)di *Referensi AWS CLI Perintah*. 

### `verify-pin-data`
<a name="payment-cryptography-data_VerifyPinData_cli_2_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`verify-pin-data`.

**AWS CLI**  
**Untuk memverifikasi PIN**  
`verify-pin-data`Contoh berikut memvalidasi PIN untuk PAN.  

```
aws payment-cryptography-data verify-pin-data \
    --verification-key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/37y2tsl45p5zjbh2 \
    --encryption-key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/ivi5ksfsuplneuyt \
    --primary-account-number 171234567890123 \
    --pin-block-format ISO_FORMAT_0 \
    --verification-attributes VisaPin="{PinVerificationKeyIndex=1,VerificationValue=5507}" \
    --encrypted-pin-block AC17DC148BDA645E
```
Output:  

```
{
    "VerificationKeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/37y2tsl45p5zjbh2",
    "VerificationKeyCheckValue": "7F2363",
    "EncryptionKeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/ivi5ksfsuplneuyt",
    "EncryptionKeyCheckValue": "7CC9E2",
}
```
Untuk informasi selengkapnya, lihat [Verifikasi data PIN](https://docs.aws.amazon.com/payment-cryptography/latest/userguide/verify-pin-data.html) di *Panduan Pengguna Kriptografi AWS Pembayaran*.  
+  Untuk detail API, lihat [VerifyPinData](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/payment-cryptography-data/verify-pin-data.html)di *Referensi AWS CLI Perintah*. 