apache / paimon-webui

Web ui for Apache Paimon.
https://paimon.apache.org/
Apache License 2.0
121 stars 58 forks source link

[Feature] Introduce encryption algorithm #509

Open hdygxsj opened 1 month ago

hdygxsj commented 1 month ago

Purpose

close #391 . Integrating cryptographic algorithm APIs for password encryption throughout the project, as well as providing implementations of national cryptographic standards (Chinese domestic algorithms).

How to use

Configuration.

paimon:
  web:
    cryptography:
      digester:
        algorithm: sm3
      symmetric:
        algorithm: sm4
        properties:
          secret-key: ${SECRET_KEY}

Use Api.

    @Autowire
    private SymmetricCryptoService symmetricCryptoService;

    @Autowire
    private DigesterService digesterService;

Tests

org.apache.paimon.web.cryptography.Sm3DigesterServiceTest. org.apache.paimon.web.cryptography.Sm4SymmetricCryptoServiceTest.

API and Format

/** DigesterService. */
public interface DigesterService {

    /** Digest. */
    String digestHex(String data);

    /** Digest with salt. */
    String digestHex(String data, String salt);
}
/** SymmetricCryptoService. */
public interface SymmetricCryptoService {

    /** Encrypt. */
    String encrypt(String data);

    /** Decrypt. */
    String decrypt(String data);
}

Documentation