%response.Charset = "utf-8"%> <% enc = Trim(request.form("ENC")) dec = Trim(request.form("DEC")) g_bszUser_key = Trim(request.form("KEY")) g_bszCounter = Trim(request.form("CTR")) Dim arrEnc Dim arrDec dim sampleData1 dim sampleData2 Dim enc2 Dim dec2 If(IsNull(g_bszUser_key) Or Len(Trim(g_bszUser_key))=0) Then g_bszUser_key = "88,E3,4F,8F,08,17,79,F1,E9,F3,94,37,0A,D4,05,89" End If If(IsNull(g_bszCounter) Or Len(Trim(g_bszCounter))=0) Then g_bszCounter = "00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,FE" 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_bszUser_key,",") redim sampleKey1(ubound(arrKey)) for i=0 to (ubound(arrKey)) sampleKey1(i) = (Cbyte)("&H" & (right("0000" & arrKey(i), 4))) Next arrCTR = split(g_bszCounter,",") redim sampleCTR1(ubound(arrCTR)) for i=0 to (ubound(arrCTR)) sampleCTR1(i) = (Cbyte)("&H" & (right("0000" & arrCTR(i), 4))) Next enc2 = test1(sampleData1,sampleKey1,sampleCTR1) 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_bszUser_key,",") redim sampleKey1(ubound(arrKey)) for i=0 to (ubound(arrKey)) sampleKey1(i) = (Cbyte)("&H" & (right("0000" & arrKey(i), 4))) Next arrCTR = split(g_bszCounter,",") redim sampleCTR1(ubound(arrCTR)) for i=0 to (ubound(arrCTR)) sampleCTR1(i) = (Cbyte)("&H" & (right("0000" & arrCTR(i), 4))) Next dec2 = test2(sampleData2,sampleKey1,sampleCTR1) End If function test1(bszPlainText,g_bszUser_key,g_bszCounter) Dim i Dim bszChiperText Dim temp '방법1 bszChiperText = KISA_SEED_CTR.SEED_CTR_Encrypt(g_bszUser_key, g_bszCounter, 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 EncRmainLeng ' Dim message_length ' Dim process_blockLeng ' Dim remainleng ' Dim nPlainTextPadding ' ' Set info = new KISA_SEED_INFO_4CTR ' outlen = 0 ' nRetOutLeng = 0 ' EncRmainLeng = 0 ' process_blockLeng = 32 ' ' Dim newpbszPlainText ' ' message_length = UBound(bszPlainText)+1 ' ' nPlainTextPadding = KISA_SEED_CTR.BLOCK_SIZE_CTR - (DMOD(message_length,KISA_SEED_CTR.BLOCK_SIZE_CTR)) ' ' 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_CTR.SEED_CTR_init( info, KISA_SEED_CTR.KISA_ENCRYPT, g_bszUser_key, g_bszCounter ) ' ' i = 0 ' Do While (i< message_length - process_blockLeng) ' Call arraycopy_system(bszPlainText, i, newpbszPlainText, 0, process_blockLeng) ' data = KISA_SEED_CTR.chartoint32_for_SEED_CTR(newpbszPlainText, process_blockLeng) ' Call KISA_SEED_CTR.SEED_CTR_Process( info, data, process_blockLeng, outbuf, nRetOutLeng ) ' cdata = KISA_SEED_CTR.int32tochar_for_SEED_CTR(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_CTR.chartoint32_for_SEED_CTR(newpbszPlainText, remainleng) ' Call KISA_SEED_CTR.SEED_CTR_Process( info, data, remainleng, outbuf, nRetOutLeng ) ' Call KISA_SEED_CTR.SEED_CTR_Close( info, outbuf, nRetOutLeng, EncRmainLeng ) ' cdata = KISA_SEED_CTR.int32tochar_for_SEED_CTR(outbuf, nRetOutLeng - EncRmainLeng) ' Call arraycopy_system(cdata, 0, bszChiperText, i, nRetOutLeng - EncRmainLeng ) ' message_length = i+ remainleng - nPaddingLeng-1 ' ' for i=0 to message_length ' temp = temp & Right("0000" & hex(bszChiperText(i)), 2) ' If(i <> message_length) then ' temp = temp & "," ' End if ' Next ' ' test1 = temp end function function test2(bszPlainText,g_bszUser_key,g_bszCounter) Dim i Dim bszChiperText Dim temp '방법1 bszChiperText = KISA_SEED_CTR.SEED_CTR_Encrypt(g_bszUser_key, g_bszCounter, 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 test2 = temp ' '방법2 ' Dim info ' Dim outbuf ' Dim data ' Dim cdata ' Dim outlen ' Dim nRetOutLeng ' Dim EncRmainLeng ' Dim message_length ' Dim process_blockLeng ' Dim remainleng ' Dim nPlainTextPadding ' ' Set info = new KISA_SEED_INFO_4CTR ' outlen = 0 ' nRetOutLeng = 0 ' EncRmainLeng = 0 ' process_blockLeng = 32 ' ' Dim newpbszPlainText ' ' message_length = UBound(bszPlainText)+1 ' ' nPlainTextPadding = KISA_SEED_CTR.BLOCK_SIZE_CTR - (DMOD(message_length,KISA_SEED_CTR.BLOCK_SIZE_CTR)) ' ' 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_CTR.SEED_CTR_init( info, KISA_SEED_CTR.KISA_ENCRYPT, g_bszUser_key, g_bszCounter ) ' ' i = 0 ' Do While (i< message_length - process_blockLeng) ' Call arraycopy_system(bszPlainText, i, newpbszPlainText, 0, process_blockLeng) ' data = KISA_SEED_CTR.chartoint32_for_SEED_CTR(newpbszPlainText, process_blockLeng) ' Call KISA_SEED_CTR.SEED_CTR_Process( info, data, process_blockLeng, outbuf, nRetOutLeng ) ' cdata = KISA_SEED_CTR.int32tochar_for_SEED_CTR(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_CTR.chartoint32_for_SEED_CTR(newpbszPlainText, remainleng) ' Call KISA_SEED_CTR.SEED_CTR_Process( info, data, remainleng, outbuf, nRetOutLeng ) ' Call KISA_SEED_CTR.SEED_CTR_Close( info, outbuf, nRetOutLeng, EncRmainLeng ) ' cdata = KISA_SEED_CTR.int32tochar_for_SEED_CTR(outbuf, nRetOutLeng - EncRmainLeng) ' Call arraycopy_system(cdata, 0, bszChiperText, i, nRetOutLeng - EncRmainLeng ) ' message_length = i+ remainleng - nPaddingLeng-1 ' ' for i=0 to message_length ' temp = temp & Right("0000" & hex(bszChiperText(i)), 2) ' If(i <> message_length) then ' temp = temp & "," ' End if ' Next ' ' test2 = temp end function %>