ㅇ. 소스코드
public
class CFB_OFB {

public static void encSSN(String input)

         throws Exception {

         // key값 구함

         KeyGenerator keygenerator = KeyGenerator.getInstance("DES");

         keygenerator.init(new SecureRandom());

         SecretKey key = keygenerator.generateKey();

 

         // key값으로 암호화함(CFB or OFB)

         Cipher cipher = Cipher.getInstance("DES/CFB/NoPadding");

         //Cipher cipher = Cipher.getInstance("DES/OFB/NoPadding");

         cipher.init(Cipher.ENCRYPT_MODE, key);

         byte[] plainTextBytes = input.getBytes("UTF-8");

         byte[] cipherTextBytes= cipher.doFinal(plainTextBytes);

 

         System.out.println("plainTextString[" + input + "]");

         System.out.println("plainTextBytes.length[" + plainTextBytes.length + "]");

         System.out.println("cipherTextBytes.length[" + cipherTextBytes.length + "]");

}

public static void main(String[] args) {

         // 파라미터 확인

         if (args.length != 1) {

                  System.out.println("해쉬 할 내용을 입력해 주세요. ex)plainText hoho");

                  return;

         }

         String arg = args[0];

         try {

                  encSSN(arg);

         } catch (Exception exception) {

                  exception.printStackTrace();

         }

}

}

ㅇ. 실행화면

사용자 삽입 이미지

Posted by 파이팅야
,