보안이 강화된 요즘 비밀번호 찾기를 하면 임시비밀번호를 발급해야 할때가 있다

그런데 막상 임시 비밀번호를 만들려고 하면 난감할때가 있다

그냥 숫자 8자리를 랜덤하게 만들까 하는 생각도 해보곤했는데

그래도 숫자와 문자를 합쳐서 만드는게 보기에도 좋을것 같아서

함수를 만들어 봤다.

 

'지정길이로 랜덤 숫자 만들기 (최대 15자리)
Function Func_getRndNum(ByVal rLen)
 IF rLen > 15 Then rLen = 15
  
 Dim idx, rndSeed, rndSeed2
 rndSeed = ""
 rndSeed2 = "1"
 
 For idx = 1 To rLen
  rndSeed = rndSeed &"1"
  rndSeed2 = rndSeed2 &"0"
 Next
 
 rndSeed = Int(rndSeed)
 rndSeed2 = Int(rndSeed2)
 
 Randomize
 
 Func_getRndNum = Int(Rnd(rndSeed)*rndSeed2)

End Function

 

'지정길이로 랜덤 문자 만들기

Function Func_getRndChr(ByVal rLen)

 Dim rtnStr
 
 Randomize
 
 For idx = 1 To rLen
  rtnStr = rtnStr & Chr(Int(2*Rnd)*32 + Int((90-65+1)*Rnd + 65))
 Next
 
 Func_getRndChr = rtnStr

End Function

 

 

이렇게 2가지 함수를 만든 다음

 

  strImsi1 = Func_getRndChr(4)
  strImsi2 = Func_getRndNum(5)
  
  imsiPwd = strImsi1 & strImsi2

이런식으로 비밀번호를 만들수 있다.

 

 

 

 

 

좀더 복잡한 비밀번호를 만들수도 있지만 이정도면 충분하지 않을까 싶다

문자 4개와 숫자 5개로 구성된 임시 비밀번호를 생성한 다음 기존 비밀번호 대신 DB에 입력하고 메일로 이 비밀번호를 전송하면 될것 같다.

top


'==================================================
' 원격지 파일을 읽어들인다.
'   호출 방법    :  getSiteSourceGet( siteURL, params )
'==================================================
Function getSiteSourceGet( siteURL, params )
 Set httpObj = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
 
 if Request.ServerVariables("HTTPS") = "on" then
  if instr(1,siteURL,"https://") < 1 then
   siteURL = "https://" & Request.ServerVariables("HTTP_HOST") & siteURL
  end if
 else
  if instr(1,siteURL,"http://") < 1 then
   siteURL = "http://" & Request.ServerVariables("HTTP_HOST") & siteURL
  end if
 End If 

 if len(params) > 0 then
  httpObj.open "GET", siteURL & "?" & params, False
 else
  httpObj.open "GET", siteURL, False
 end if
 
 httpObj.Send()
 httpObj.WaitForResponse
 If httpObj.Status = "200" Then
  getSiteSourceGet = httpObj.ResponseText
 Else
  getSiteSourceGet = null
 End If
End Function

top


'==================================================
'   한글과 영문을 구분해서 문자열 잘라서 Return
'   호출 방법    :  getCutString(문자열, 원하는 글자수)
' 입력 파라메터: strData(문자열,int글자)
'==================================================
Function getCutString(strString, intCutLen)
    Dim intLen '// 문자열 길이
    Dim intByte '// byte 수
    Dim strCutString
    Dim strRes
    Dim strChar
    Dim intX
    intLen = 0
    intByte = 0
    strRes = ""
    if IsNULL(strString) then
     intLen = 0
    else
     intLen = Len(trim(strString))
    end if
      

    For intX = 1 to intLen
        strChar = ""
        strCutString = Mid(strString, intX, 1)        '//    일단 1만큼 잘라서 strCutString에 저장한다.
        strChar = Asc(strCutString)        '//    아스키 코드값 읽어오기
        strChar = Left(strChar, 1)
        If strChar = "-" Then            '//    "-"이면 2바이트 문자임
            intByte = intByte + 2
        Else
            intByte = intByte + 1
        End If
        If intCutLen < intByte Then
            '// 현재 문자열 byte 수가 지정한 byte 수보다 크면 For 문을 빠져나간다.
            strRes = strRes & "..."
            Exit For
        Else
            '// 현재 문자열 byte 수가 지정한 byte 수보다 작으면 strRes 에 잘라낸 문자열을 추가한다.
            strRes = strRes & strCutString
        End If
    Next
    getCutString = strRes
End Function

'개발팁( ASP )' 카테고리의 다른 글

임시비밀번호 만들기  (0) 2013.07.12
원격지 파일을 읽기  (0) 2013.07.09
한글과 영문을 구분해서 문자열의 길이를 Return  (0) 2013.07.02
top