%response.Charset = "utf-8"%> <% enc = Trim(request.form("ENC")) dec = Trim(request.form("DEC")) g_pbUserKey = Trim(request.form("KEY")) Dim arrEnc Dim arrDec dim sampleData1 dim sampleData2 Dim enc2 Dim dec2 Dim arrKey If(IsNull(g_pbUserKey) Or Len(Trim(g_pbUserKey))=0) Then g_pbUserKey = "2B,7E,15,16,28,AE,D2,A6,AB,F7,15,88,09,CF,4F,3C" End if If(IsNull(enc) Or Len(Trim(enc))=0) Then Else arrEnc = split(enc,",") redim sampleData1(ubound(arrEnc)) for i=0 to (ubound(arrEnc)) sampleData1(i) = (Cbyte)("&H" & (right("0000" & arrEnc(i), 4))) Next arrKey = split(g_pbUserKey,",") redim sampleKey1(ubound(arrKey)) for i=0 to (ubound(arrKey)) sampleKey1(i) = (Cbyte)("&H" & (right("0000" & arrKey(i), 4))) Next enc2 = test1(sampleData1,sampleKey1) End If If(IsNull(dec) Or Len(Trim(dec))=0) Then Else arrDec = split(dec,",") redim sampleData2(ubound(arrDec)) for i=0 to (ubound(arrDec)) sampleData2(i) = (Cbyte)("&H" & (right("0000" & arrDec(i), 4))) Next arrKey = split(g_pbUserKey,",") redim sampleKey1(ubound(arrKey)) for i=0 to (ubound(arrKey)) sampleKey1(i) = (Cbyte)("&H" & (right("0000" & arrKey(i), 4))) Next dec2 = test2(sampleData2,sampleKey1) End If function test1(bszPlainText,g_bszUser_key) Dim i Dim bszChiperText Dim temp '방법1 bszChiperText = KISA_SEED_ECB.SEED_ECB_Encrypt(g_bszUser_key, bszPlainText, 0, UBound(bszPlainText)+1) for i=0 to (UBound(bszChiperText)) temp = temp & Right("0000" & hex(bszChiperText(i)), 2) If(i <> UBound(bszChiperText)) then temp = temp & "," End if Next test1 = temp ' '방법2 ' Dim info ' Dim outbuf ' Dim data ' Dim cdata ' Dim outlen ' Dim nRetOutLeng ' Dim nPaddingLeng ' Dim message_length ' Dim process_blockLeng ' Dim remainleng ' ' Set info = new KISA_SEED_INFO_4ECB ' outlen = 0 ' nRetOutLeng = 0 ' nPaddingLeng = 0 ' process_blockLeng = 32 ' ' Dim newpbszPlainText ' ' message_length = UBound(bszPlainText)+1 ' ' nPlainTextPadding = KISA_SEED_ECB.BLOCK_SIZE_SEED - (DMOD(message_length,KISA_SEED_ECB.BLOCK_SIZE_SEED)) ' ' ReDim newpbszPlainText(process_blockLeng-1) ' ' ReDim bszChiperText(message_length + nPlainTextPadding -1) ' ' outlen = process_blockLeng/4 ' ReDim outbuf(outlen-1) ' Call arrayinit(outbuf, 0, outlen) ' ' Call KISA_SEED_ECB.SEED_ECB_init( info, KISA_SEED_ECB.KISA_ENCRYPT, g_bszUser_key ) ' ' i = 0 ' Do While (i< message_length - process_blockLeng) ' Call arraycopy_system(bszPlainText, i, newpbszPlainText, 0, process_blockLeng) ' data = KISA_SEED_ECB.chartoint32_for_SEED_ECB(newpbszPlainText, process_blockLeng) ' Call KISA_SEED_ECB.SEED_ECB_Process( info, data, process_blockLeng, outbuf, nRetOutLeng ) ' cdata = KISA_SEED_ECB.int32tochar_for_SEED_ECB(outbuf, nRetOutLeng) ' Call arraycopy_system(cdata, 0, bszChiperText, i, nRetOutLeng ) ' i = i + nRetOutLeng ' ' Loop ' ' remainleng = DMOD(message_length, process_blockLeng) ' If remainleng = 0 Then ' remainleng = process_blockLeng ' End If ' Call arraycopy_system(bszPlainText, i, newpbszPlainText, 0, remainleng) ' data = KISA_SEED_ECB.chartoint32_for_SEED_ECB(newpbszPlainText, remainleng) ' Call KISA_SEED_ECB.SEED_ECB_Process( info, data, remainleng, outbuf, nRetOutLeng ) ' cdata = KISA_SEED_ECB.int32tochar_for_SEED_ECB(outbuf, nRetOutLeng) ' Call arraycopy_system(cdata, 0, bszChiperText, i, nRetOutLeng ) ' ' i = i + nRetOutLeng ' ' Call KISA_SEED_ECB.SEED_ECB_Close( info, outbuf, 0, nPaddingLeng ) ' cdata = KISA_SEED_ECB.int32tochar_for_SEED_ECB(outbuf, nPaddingLeng) ' Call arraycopy_system(cdata, 0, bszChiperText, i, nPaddingLeng ) ' ' for i=0 to (UBound(bszChiperText)) ' temp = temp & Right("0000" & hex(bszChiperText(i)), 2) ' If(i <> UBound(bszChiperText)) then ' temp = temp & "," ' End if ' Next ' ' test1 = temp end function function test2(bszChiperText,g_bszUser_key) Dim i Dim bszPlainText Dim temp '방법 1 bszPlaintext = KISA_SEED_ECB.SEED_ECB_Decrypt(g_bszUser_key, bszChiperText, 0, UBound(bszChiperText)+1) If isnull(bszPlaintext) Then else for i=0 to (UBound(bszPlaintext)) temp = temp & Right("0000" & hex(bszPlaintext(i)), 2) If(i <> UBound(bszPlaintext)) then temp = temp & "," End if Next End if test2 = temp ' '방법2 ' Dim info ' Dim outbuf ' Dim data ' Dim cdata ' Dim outlen ' Dim nRetOutLeng ' Dim nPaddingLeng ' Dim message_length ' Dim process_blockLeng ' Dim remainleng ' ' Set info = new KISA_SEED_INFO_4ECB ' outlen = 0 ' nRetOutLeng = 0 ' nPaddingLeng = 0 ' process_blockLeng = 32 ' ' Dim newpbszChiperText ' ' message_length = UBound(bszChiperText)+1 ' ' If DMOD(message_length,KISA_SEED_ECB.BLOCK_SIZE_SEED) >0 Then ' test2 = temp ' Exit Function ' End if ' ' ReDim newpbszChiperText(process_blockLeng-1) ' ' ReDim bszPlaintext(message_length-1) ' ' outlen = process_blockLeng/4 ' ReDim outbuf(outlen-1) ' Call arrayinit(outbuf, 0, outlen) ' ' Call KISA_SEED_ECB.SEED_ECB_init( info, KISA_SEED_ECB.KISA_DECRYPT, g_bszUser_key ) ' ' i = 0 ' Do While (i< message_length - process_blockLeng) ' Call arraycopy_system(bszChiperText, i, newpbszChiperText, 0, process_blockLeng) ' data = KISA_SEED_ECB.chartoint32_for_SEED_ECB(newpbszChiperText, process_blockLeng) ' Call KISA_SEED_ECB.SEED_ECB_Process( info, data, process_blockLeng, outbuf, nRetOutLeng ) ' cdata = KISA_SEED_ECB.int32tochar_for_SEED_ECB(outbuf, nRetOutLeng) ' Call arraycopy_system(cdata, 0, bszPlaintext, i, nRetOutLeng ) ' i = i + nRetOutLeng ' Loop ' ' remainleng = DMOD(message_length, process_blockLeng) ' If remainleng = 0 Then ' remainleng = process_blockLeng ' End If ' Call arraycopy_system(bszChiperText, i, newpbszChiperText, 0, remainleng) ' data = KISA_SEED_ECB.chartoint32_for_SEED_ECB(newpbszChiperText, remainleng) ' Call KISA_SEED_ECB.SEED_ECB_Process( info, data, remainleng, outbuf, nRetOutLeng ) ' ' if KISA_SEED_ECB.SEED_ECB_Close( info, outbuf, nRetOutLeng, nPaddingLeng ) > 0 then ' cdata = KISA_SEED_ECB.int32tochar_for_SEED_ECB(outbuf, remainleng- nPaddingLeng) ' Call arraycopy_system(cdata, 0, bszPlaintext, i, remainleng - nPaddingLeng ) ' message_length = i+ remainleng - nPaddingLeng-1 ' ' for i=0 to message_length ' temp = temp & Right("0000" & hex(bszPlaintext(i)), 2) ' If (i <> message_length) Then ' temp = temp & "," ' End if ' Next ' End if ' ' test2 = temp end function %>