package xxx.xxx.util;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
public class PasswordUtil {
public static final int KEY_LENTH = 2;
/**
* 初期パスワードを生成するメソッドです
*
* @throws NoSuchAlgorithmException
* @returnパスワード
*/
public static String generateKey() throws NoSuchAlgorithmException {
String resultStr = null;
// 候補文字列
String[] candidates = new String[] { "abcdefghijklmnopqrstuvwxyz",
"0123456789" };
int count = KEY_LENTH;
char[] generated = new char[count];
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
StringBuffer candidateAll = new StringBuffer();
int watermark = 0;
for (int i = 0; i < candidates.length; i++) {
if (candidates[i] != null && !"".equals(candidates[i])) {
generated[watermark++] = candidates[i].charAt(sr.nextInt(candidates[i].length()));
candidateAll.append(candidates[i]);
}
}
for (int i = watermark; i < count; i++) {
generated[i] = candidateAll.toString()
.charAt(sr.nextInt(candidateAll.length()));
}
for (int i = 100000; i >= 0; i--) {
int x = sr.nextInt(count);
int y = sr.nextInt(count);
char tmp = generated[x];
generated[x] = generated[y];
generated[y] = tmp;
}
resultStr = new String(generated);
return resultStr;
}// GEN-LAST:event_jButton1ActionPerformed
}
vba로 간단하게 엑셀의 데이터를 업데이트 문 만들기…
엑셀2007기준
엑셀->옵션->기본설정->개발탭표시.
개발탭클릭->Visual basic 클릭->시트1클릭.
아래 코드를 붙여넣기
Sub default() Dim SQL As String Dim i As Long For i = 2 To 2 SQL = "UPDATE `db명`.`테이블명` SET " '칼럼이 만으면 (i, 2), (i, 3), (i, 4)로 조함 SQL = SQL & "`칼럼명` = '" & Sheet1.Cells(i, 1).Value & "', " & vbNewLine '조건 SQL = SQL & " WHERE `xe_school_data`.`document_srl` =" & Sheet1.Cells(i, 110) '시트2의 칼럼에 케리문을 양도함 '.sql파일로 만들어서 저장해도 됨. Sheet2.Cells(i, 1).Value = SQL Next i End Sub
이렇게 하면 일일이 sql문을 만들필요 없음.









Recent Comments