ASP Base64
<%
Option Explicit

Dim sBASE_64_CHARACTERS, sBASE_64_CHARACTERSansi
sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
sBASE_64_CHARACTERSansi = strUnicode2Ansi(sBASE_64_CHARACTERS)

Function strUnicodeLen(asContents)
 Dim asContents1 : asContents1 ="a" & asContents
 Dim Len1  : Len1=Len(asContents1)
 Dim K  : K=0
 Dim I, Asc1
 
 For I=1 To Len1
  Asc1 = asc(mid(asContents1,I,1))
  IF Asc1 < 0 Then Asc1 = 65536 + Asc1
  IF Asc1 > 255 Then
   K = K + 2
  ELSE
   K = K + 1
  End IF
 Next
 
 strUnicodeLen = K - 1
End Function

Function strUnicode2Ansi(asContents)
 Dim Len1   : Len1 = Len(asContents)
 Dim I, VarCHAR, VarASC, VarHEX, VarLOW, VarHIGH

 strUnicode2Ansi = ""
 
 For I = 1 to Len1
  VarCHAR = Mid(asContents,I,1)
  VarASC = Asc(VarCHAR)
  IF VarASC < 0 Then VarASC = VarASC + 65536
  IF VarASC > 255 Then
   VarHEX  = Hex(VarASC)
   VarLOW  = Left(VarHEX,2)
   VarHIGH  = Right(VarHEX,2)
   strUnicode2Ansi = strUnicode2Ansi & ChrB("&H" & VarLOW ) & ChrB("&H" & VarHIGH )
  Else
   strUnicode2Ansi = strUnicode2Ansi & ChrB(VarASC)
  End IF
 Next
End Function

 

Function strAnsi2Unicode(asContents)
 Dim Len1   : Len1  = LenB(asContents)
 Dim VarCHAR, VarASC, I

 strAnsi2Unicode = ""
 
 IF Len1=0 Then Exit Function
 
 For I=1 To Len1
  VarCHAR = MidB(asContents,I,1)
  VarASC = AscB(VarCHAR)
  IF VarASC > 127 Then
   strAnsi2Unicode = strAnsi2Unicode & Chr(AscW(MidB(asContents, I+1,1) & VarCHAR))
   I  = I + 1
  Else
   strAnsi2Unicode = strAnsi2Unicode & Chr(VarASC)
  End IF
 Next
 
End function

Function Base64encode(asContents)
 Dim lnPosition
 Dim lsResult
 Dim Char1
 Dim Char2
 Dim Char3
 Dim Char4
 Dim Byte1
 Dim Byte2
 Dim Byte3
 Dim SaveBits1
 Dim SaveBits2
 Dim lsGroupBinary
 Dim lsGroup64
 Dim M3, M4, Len1, Len2

 Len1   =LenB(asContents)
 
 IF Len1 < 1 Then
  Base64encode = ""
  Exit Function
 End IF

 M3=Len1 Mod 3
 
 IF M3 > 0 Then asContents = asContents & String(3 - M3, ChrB(0))

 IF m3 > 0 Then
  Len1 = Len1 + (3 - M3)
  Len2 = Len1 - 3
 Else
  Len2 = Len1
 End IF

 lsResult = ""

 For lnPosition = 1 To Len2 Step 3
  lsGroup64 = ""
  lsGroupBinary = MidB(asContents, lnPosition, 3)

  Byte1  = AscB(MidB(lsGroupBinary, 1, 1)) : SaveBits1 = Byte1 And 3
  Byte2  = AscB(MidB(lsGroupBinary, 2, 1)) : SaveBits2 = Byte2 And 15
  Byte3  = AscB(MidB(lsGroupBinary, 3, 1))

  Char1  = MidB(sBASE_64_CHARACTERSansi, ((Byte1 And 252) \ 4) + 1, 1)
  Char2  = MidB(sBASE_64_CHARACTERSansi, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And &HFF) + 1, 1)
  Char3  = MidB(sBASE_64_CHARACTERSansi, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And &HFF) + 1, 1)
  Char4  = MidB(sBASE_64_CHARACTERSansi, (Byte3 And 63) + 1, 1)
  lsGroup64 = Char1 & Char2 & Char3 & Char4

  lsResult  = lsResult & lsGroup64
 Next

 IF M3 > 0 Then
  lsGroup64 = ""
  lsGroupBinary = MidB(asContents, Len2 + 1, 3)

  Byte1  = AscB(MidB(lsGroupBinary, 1, 1)) : SaveBits1 = Byte1 And 3
  Byte2  = AscB(MidB(lsGroupBinary, 2, 1)) : SaveBits2 = Byte2 And 15
  Byte3  = AscB(MidB(lsGroupBinary, 3, 1))

  Char1  = MidB(sBASE_64_CHARACTERSansi, ((Byte1 And 252) \ 4) + 1, 1)
  Char2  = MidB(sBASE_64_CHARACTERSansi, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And &HFF) + 1, 1)
  Char3  = MidB(sBASE_64_CHARACTERSansi, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And &HFF) + 1, 1)

  IF M3=1 Then
   lsGroup64 = Char1 & Char2 & ChrB(61) & ChrB(61)
  Else
   lsGroup64 = Char1 & Char2 & Char3 & ChrB(61)
  End IF

  lsResult  = lsResult & lsGroup64
 End IF

 Base64encode = lsResult
End Function

Function Base64decode(asContents)
 Dim lsResult
 Dim lnPosition
 Dim lsGroup64, lsGroupBinary
 Dim Char1, Char2, Char3, Char4
 Dim Byte1, Byte2, Byte3
 Dim M4, Len1, Len2

 Len1 = LenB(asContents)
 M4 = Len1 Mod 4

 IF Len1 < 1 Or M4 > 0 Then
  Base64decode = ""
  Exit Function
 End IF

 IF MidB(asContents, Len1, 1) = ChrB(61) Then M4 = 3
 IF MidB(asContents, Len1-1, 1) = ChrB(61) Then M4 = 2

 IF M4 = 0 Then
  Len2 = Len1
 Else
  Len2 = Len1 - 4
 End IF

 For lnPosition = 1 To Len2 Step 4
  lsGroupBinary = ""
  lsGroup64 = MidB(asContents, lnPosition, 4)

  Char1  = InStrB(sBASE_64_CHARACTERSansi, MidB(lsGroup64, 1, 1)) - 1
  Char2  = InStrB(sBASE_64_CHARACTERSansi, MidB(lsGroup64, 2, 1)) - 1
  Char3  = InStrB(sBASE_64_CHARACTERSansi, MidB(lsGroup64, 3, 1)) - 1
  Char4  = InStrB(sBASE_64_CHARACTERSansi, MidB(lsGroup64, 4, 1)) - 1

  Byte1  = ChrB(((Char2 And 48) \ 16) Or (Char1 * 4) And &HFF)
  Byte2  = lsGroupBinary & ChrB(((Char3 And 60) \ 4) Or (Char2 * 16) And &HFF)
  Byte3  = ChrB((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63))
  lsGroupBinary = Byte1 & Byte2 & Byte3

  lsResult  = lsResult & lsGroupBinary
 Next

 IF M4 > 0 Then
  lsGroupBinary = ""
  lsGroup64 = MidB(asContents, Len2 + 1, M4) & ChrB(65)
  IF M4=2 Then
   lsGroup64 = lsGroup64 & chrB(65)
  End IF
  Char1 = InStrB(sBASE_64_CHARACTERSansi, MidB(lsGroup64, 1, 1)) - 1
  Char2 = InStrB(sBASE_64_CHARACTERSansi, MidB(lsGroup64, 2, 1)) - 1
  Char3 = InStrB(sBASE_64_CHARACTERSansi, MidB(lsGroup64, 3, 1)) - 1
  Char4 = InStrB(sBASE_64_CHARACTERSansi, MidB(lsGroup64, 4, 1)) - 1

  Byte1 = ChrB(((Char2 And 48) \ 16) Or (Char1 * 4) And &HFF)
  Byte2 = lsGroupBinary & ChrB(((Char3 And 60) \ 4) Or (Char2 * 16) And &HFF)
  Byte3 = ChrB((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63))

  IF M4=2 Then
   lsGroupBinary = Byte1
  elseIF M4=3 Then
   lsGroupBinary = Byte1 & Byte2
  end IF

  lsResult   = lsResult & lsGroupBinary
 End IF

 Base64decode   = lsResult
End Function

 


Dim ORIGNvalue : ORIGNvalue = "mTVisman123456"
Dim EncodeA : EncodeA = StrReverse(strAnsi2Unicode(Base64encode(strUnicode2Ansi(ORIGNvalue))))
Dim DecodeA : DecodeA = strAnsi2Unicode(Base64decode(strUnicode2Ansi(StrReverse(EncodeA))))

response.write "[" & DecodeA & "] was encoded to [" & EncodeA & "]<BR>"
response.write "[" & EncodeA & "] was decoded to [" & DecodeA & "]<BR>"
%>



PHP Base64
<?
$Str = 'mTVisman123456';
$Test = base64_encode($Str);
$TestD = base64_decode($Test);
printf($Test.$TestD);
?>


JSP Base64
<%@ page import="java.net.*, java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.lang.String" %>
<%@ page import="java.security.*" %>
<%@ page import="sun.misc.BASE64Encoder" %>
<%@ page import="sun.misc.BASE64Decoder" %>
<%
        BASE64Encoder encoder = new BASE64Encoder();
        BASE64Decoder decoder = new BASE64Decoder();

        String StrOUT, Reversing;
        byte[] b1, CookieString;


 
  String Test = "
=YTN0@j@x4WYtN*aWRVb";

  Reversing = new StringBuffer(Test).toString();
        CookieString = decoder.decodeBuffer(Reversing);

        StrOUT = new String(CookieString, "ISO-8859-1");

  out.println("[" + StrOUT + "] was decoded to [" + Test + "]<br>");
        out.println("[" + Test + "] was decoded to [" + StrOUT + "]");
%>


출저:http://cafe.naver.com/webexploit/3

'개발 언어 > JSP' 카테고리의 다른 글

Encoding and Decoding base64 with (ASP,PHP,JSP)  (0) 2008/03/25
Posted by 하늘높이!!

댓글을 달아주세요:: 네티켓은 기본, 스팸은 사절

에러 원인: 함수구현 부분에도 세미콜론을 붙인 경우..


함수 prototype에는 ;(세미콜론)을 사용한다.

ex)

void add(int ,int ); -> 세미콜른을 붙여야한다.

void main()
{
    int sum;

    sum = add(10,20);
}

void add(int x,int y); <- 함수구현 부분에도 세미콜론을 붙인 경우..
{
    return x+y;
}

 

출저: http://zeronova.egloos.com/1209718

Posted by 하늘높이!!

댓글을 달아주세요:: 네티켓은 기본, 스팸은 사절

//폰트 다운이 완료되었다면
void downFont_Completed(object sender, EventArgs e)
{
    //다운로더 객체
    Downloader downFont = sender as Downloader;

    //맑은 고딕 폰트 적용
    Font1.SetFontSource(downFont); //폰트 리소스 할당
    Font1.FontFamily = "Malgun Gothic"; // "맑은고딕" 이라고 할 경우 인식X
    Font1.Text = "맑은고딕: 맑은 고딕 폰드 사용하기.";
}

Posted by 하늘높이!!

댓글을 달아주세요:: 네티켓은 기본, 스팸은 사절

강좌 제목 : ASP.NET AJAX와 Silverlight를 활용한 RIA 구현

http://www.taeyo.pe.kr/Lecture/WPFE/ria01.asp

rototype.js 를 위한 개발자 노트

http://openframework.or.kr/framework_reference/prototype_js/1.4.0/prototype.js.html

XAML 구조 정의(MSDN)
http://msdn2.microsoft.com/en-us/library/ms747122.aspx

ECMA Script(Scma-262)

http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf

ASP.NET AJAX가 궁금해?

http://www.bullog.net/Web/Columns/TOC.aspx?ca=12

Posted by 하늘높이!!

댓글을 달아주세요:: 네티켓은 기본, 스팸은 사절

IronPython

2008/03/12 15:45

IronPython

위키백과 ― 우리 모두의 백과사전.

Jump to: navigation, 찾기

IronPython마이크로소프트에서 개발하는 파이썬의 구현 중 하나로, 처음에는 Jim Hugunin이 .NETMono를 위해 개발하였다. 버전 1.0은 2006년 9월 5일에 발표되었다.

  • IronPython 프로젝트 페이지
  • CPython과 IronPython의 차이점

  • 출저:http://ko.wikipedia.org/wiki/IronPython

    '개발 언어' 카테고리의 다른 글

    IronPython  (0) 2008/03/12
    Posted by 하늘높이!!

    댓글을 달아주세요:: 네티켓은 기본, 스팸은 사절

    http://openframework.or.kr/framework_reference/prototype_js/1.4.0/prototype.js.html

    prototype.jsSam Stephenson에 의해 작성된 자바스크립트 라이브러리이다. 이 놀랍도록 멋진 생각과 표준에 의해 잘 작성된 코드의 일부는 웹2.0의 특성을 나타내는 풍부하고 상호작용하는 웹페이지와 많은 연관을 가진다.

    만약 당신이 최근 이 라이브러리를 사용하기 시작했다면, 당신은 아마도 이 문서가 가장 좋은 지시사항중에 하나는 아니라는것을 알아차렸을것이다. 나 이전에 다른 많은 개발자들처럼, 나는 소스코드와 이것을 사용한 경험에서 prototype.js에 대한 지식을 가지게 되었다. 나는 모든 이가 배우고 공유하는 동안 좀더 많은 정보를 얻게 되는게 가장 좋은 것이라고 생각한다.

    나는 objects, classes, functions, 그리고 이 라이브러리에 의해 제공되는 확장을 위한 비공식적인 참조문서 또한 제공한다.

    당신이 예제와 참조문서를 읽었을때, Ruby프로그래밍 언어에 친숙한 개발자는 Ruby의 내장 클래스와 이 라이브러리에 의해 구현된 많은 확장 사이의 의도적인 유사성을 알아차리게 될것이다.

    '개발 언어 > JAVASCRIPT' 카테고리의 다른 글

    Prototype.js  (0) 2008/03/12
    Posted by 하늘높이!!

    댓글을 달아주세요:: 네티켓은 기본, 스팸은 사절


    BLOG main image
    by 하늘높이!!
    Candle

    공지사항

    카테고리

    분류 전체보기 (64)
    내 생각에는..... (8)
    UX (15)
    Media (18)
    하드웨어 (1)
    개발 언어 (5)
    블로그 놀이 (5)
    리눅스 (8)

    최근에 받은 트랙백