SenseID Private Cloud
1.7.0, 日本語, 1v1
1.7.0, 日本語, 1v1
  • イントロダクション
  • 1. UDID 取得ツール
  • 2. プライベートクラウドファイルのライセンスに関する説明
  • 3. プライベートクラウドの展開方法
  • 4. プライベートクラウドの展開に関する FAQ
  • 5. 個人データの暗号化
  • 6. API リファレンス
    • 6.1. 顔の比較 (ステートレス)
      • 6.1.1 /identity/image_verification/stateless
      • 6.1.2. /identity/multiface_image_omni_verification/stateless
      • 6.1.3. /identity/liveness_image_verification/stateless
      • 6.1.4. /identity/silent_image_verification/stateless
    • 6.2. 画像品質チェック
      • 6.2.1. /quality/face/stateless
    • 6.3. なりすまし防止
      • 6.3.1. /liveness/silent_detection/stateless
Powered by GitBook
On this page
  • 具体的な暗号化の方法
  • Java サンプル

Was this helpful?

Export as PDF

5. 個人データの暗号化

ユーザーがアップロードした個人データは暗号化する必要があります。暗号化アルゴリズムは AES-256-CBC を使用します。暗号化に必要なキーおよび IV は、デフォルトの設定では以下のとおりです。

key = dcbbad6765e14139a07d34b92292a672
iv  = df25d188a061

変更する場合は、環境変数 PARAM_DECRYPT_KEY および PARAM_DECRYPT_IV を更新します。キーは 32 文字で、IV は 12 文字です。

具体的な暗号化の方法

  1. 人物の画像ファイルまたはその他の個人データを読み取ります。

  2. AES-256-CBC でデータを暗号化します。

  3. Base64 で上記の結果を暗号化します。

Java サンプル

import javax.crypto.Cipher;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.Charset;
import java.util.Base64;


public class AESCipher {
    private String key;
    private String iv;

    public AESCipher(String key, String iv) {
        this.key = key;
        this.iv = iv;
    }

    String encrypt(byte[] data) throws Exception{
        SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(Charset.forName("UTF-8")), "AES");
        Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
        cipher.init(Cipher.ENCRYPT_MODE, keySpec, new GCMParameterSpec(128, iv.getBytes(Charset.forName("UTF-8"))));
        byte[] result = cipher.doFinal(data);
        return Base64.getEncoder().encodeToString(result);
    }

    byte[] decrypt(String data) throws Exception {
        SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(Charset.forName("UTF-8")), "AES");
        Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
        cipher.init(Cipher.DECRYPT_MODE, keySpec, new GCMParameterSpec(128, iv.getBytes(Charset.forName("UTF-8"))));
        byte[] result = cipher.doFinal(Base64.getDecoder().decode(data));
        return result;
    }

    public static void main(String[] args) throws Exception{
        String key = "dcbbad6765e14139a07d34b92292a672"; //key 32 bits
        String iv = "df25d188a061"; // iv 12 bits
        String data = "hello world";

        AESCipher cipher = new AESCipher(key, iv);
        String encryptedData = cipher.encrypt(data.getBytes());
        System.out.println("encrypted data: " + encryptedData);

        String decryptedData = new String(cipher.decrypt(encryptedData));
        System.out.println("decrypted data: " + decryptedData);
    }
}
Previous4. プライベートクラウドの展開に関する FAQNext6. API リファレンス

Last updated 4 years ago

Was this helpful?