더북(TheBook)

서비스 제공자는 이 서비스를 구현하는 클래스를 한 개 이상 제공한다. 예를 들어 다음과 같다.

package com.corejava.crypt.impl;


import com.corejava.crypt.Cipher;


public class CaesarCipher implements Cipher {

    public byte[ ] encrypt(byte[ ] source, byte[ ] key) {

        byte[ ] result = new byte[source.length];

        for (int i = 0; i < source.length; i++)

            result[i] = (byte)(source[i] + key[0]);

        return result;

    }


    public byte[ ] decrypt(byte[ ] source, byte[ ] key) {

        return encrypt(source, new byte[ ] { (byte) -key[0] });

    }


    public int strength() { return 1; }

}

신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.