Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (日本語) » Ultra Light J » Ultra Light J の使用 » Ultra Light J アプリケーションの開発

 

データの暗号化と難読化

Ultra Light J データベース内のデータはデフォルトで暗号化されません。データは API を使用して暗号化または難読化できます。暗号化ではデータを安全に表現できますが、難読化ではデータベースの内容を不用意に閲覧されないことを目的とした簡易的なセキュリティを実現します。

♦  データベース内のデータを暗号化または難読化するには、次の手順に従います。
  1. EncryptionControl インタフェースを実装するクラスを作成します。

    次の例では、暗号化インタフェースを実装する新しいクラス Encryptor を作成しています。

    static class Encryptor
        implements EncryptionControl
    {
  2. 新しいクラスで initialize、encrypt、decrypt の各メソッドを実装します。

    クラスは次のようになります。

    static class Encryptor
        implements EncryptionControl
    {
        /** Decrypt a page stored in the database.
         * @param page_no the number of the page being decrypted
         * @param src the encrypted source page which was read from the database
         * @param tgt the decrypted page (filled in by method)
         */
        public void decrypt( int page_no, byte[] src, byte[] tgt )
            throws ULjException
        {
            // Your decryption method goes here.
        }
        
        /** Encrypt a page stored in the database.
         * @param page_no the number of the page being encrypted
         * @param src the unencrypted source
         * @param tgt the encrypted target page which will be written to the database (filled in by method)
         */
        public void encrypt( int page_no, byte[] src, byte[] tgt )
            throws ULjException
        {
            // Your encryption method goes here.
        }
        
        /** Initialize the encryption control with a password.
         * @param password the password
         */
        public void initialize(String password)
            throws ULjException
        {
            // Your initialization method goes here.
        }
    }

    EncryptionControl メソッドの詳細については、EncryptionControl インタフェースを参照してください。

  3. 新しいクラスを暗号化制御に使用するようにデータベースを設定します。

    暗号化制御は setEncryption メソッドで指定できます。次の例は、データベースの名前を参照する新しい Configuration オブジェクトである config が作成してあることを前提としています。

    config.setEncryption(new Encryptor());
  4. データベースに接続します。

    データベース内で追加または変更されるデータは暗号化されます。

注意

暗号化と難読化は非永続データベース・ストアには使用できません。

参照