AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

ClientEncryption.decrypt() (mongosh 메서드)

ClientEncryption.decrypt(encryptedValue)

ClientEncryption.decrypt() decrypts the encryptionValue if the current database connection was configured with access to the Key Management Service (KMS) and key vault used to encrypt encryptionValue.

반환합니다:

암호 해독된 값입니다.

이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

ClientEncryption.decrypt 의 구문은 다음과 같습니다:

clientEncryption = db.getMongo().getClientEncryption()
clientEncryption.decrypt(encryptedValue)

는 encryptedValue 클라이언트 사이드 필드 수준 암호화 사용하여 생성된 하위 6 binary data 유형 의 객체 여야 합니다.

Read operations issued from a database connection configured with access to the correct Key Management Service (KMS) and Key Vault can automatically decrypt field values encrypted using ClientEncryption.encrypt(). Clients only need to use decrypt() to decrypt Binary subtype 6 values not stored within a document field.

The mongosh ClientEncryption methods require a database connection with in-use encryption enabled. If the current database connection was not initiated with in-use encryption enabled, either:

다음 예에서는 클라이언트 사이드 필드 수준 암호화 구성을 위해 로컬로 managed KMS를 사용합니다.

1
  1. mongosh 시작

    실행:

    mongosh --nodb

    --nodb 데이터베이스 에 연결하지 않음을 의미합니다.

  2. 키 string생성

    기본 64 96바이트 string 을 생성합니다.

    const TEST_LOCAL_KEY = require("crypto").randomBytes(96).toString("base64")
  3. 암호화 옵션 객체 만들기

    클라이언트 사이드 필드 수준 암호화 옵션 객체 를 만들려면 이전 단계의 TEST_LOCAL_KEY string 을 사용합니다.

    var autoEncryptionOpts = {
    "keyVaultNamespace" : "encryption.__dataKeys",
    "kmsProviders" : {
    "local" : {
    "key" : BinData(0, TEST_LOCAL_KEY)
    }
    }
    }
  4. 암호화된 클라이언트 객체 만들기

    암호화됨 클라이언트 객체 를 만들려면 Mongo() 생성자를 사용합니다. mongodb://myMongo.example.net URI를 대상 클러스터 의 연결 string URI 로 바꿉니다. 예를 예시 다음과 같습니다.

    encryptedClient = Mongo(
    "mongodb://myMongo.example.net:27017/?replSetName=myMongo",
    autoEncryptionOpts
    )
2

Retrieve the ClientEncryption object and use the ClientEncryption.decrypt() method to decrypt a value encrypted by ClientEncryption.encrypt().

clientEncryption = encryptedClient.getClientEncryption();
clientEncryption.decrypt(BinData(6,"AmTi2H3xaEk8u9+jlFNaLLkC3Q/+kmwDbbWrq+h9nuv9W+u7A5a0UnpULBNZH+Q21fAztPpU09wpKPrju9dKfpN1Afpj1/ZhFcH6LYZOWSBBOAuUNjPLxMNSYOOuITuuYWo="))

If successful, decrypt() returns the decrypted value:

"123-45-6789"

클라이언트 사이드 필드 레벨 암호화가 활성화된 상태에서 MongoDB 연결을 시작하는 방법에 대한 전체 설명서는 Mongo() 를 참조하세요.

이 페이지 평가하기