반응형
랜덤키
-
영문과 숫자를 조합한 랜덤키 만들기Tech/SpringBoot 2017. 8. 2. 11:00
// 영문 + 숫자를 조합한 키 생성 public static String generateKey() throws Exception{ // 16byte 의 랜럼 수치를 저장 String key = ""; while(true) { byte[] bytes = new byte[16]; SecureRandom random = new SecureRandom(); random.nextBytes(bytes); try { key = new String(Base64.encodeBase64(bytes, false), "UTF-8").replace("==", ""); } catch (Exception e) { log.error("generateKey: "+e); throw new Exception(e); } if(key.ma..