암호화 해독 Base64 and URL and Hex Encoding and Decoding 정보
소림은 다음과 같은 코드를 추출할 수 있는 복호화 페이지를 추천했다.
html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Base64 and URL and Hex Encoding and Decoding
<br><!--
<br>function urlDecode(str){
<br> str=str.replace(new RegExp('\\+','g'),' ');
<br> return unescape(str);
<br>}
<br>function urlEncode(str){
<br> str=escape(str);
<br> str=str.replace(new RegExp('\\+','g'),'%2B');
<br> return str.replace(new RegExp('%20','g'),'+');
<br>}
<br>var END_OF_INPUT = -1;
<br>var base64Chars = new Array(
<br> 'A','B','C','D','E','F','G','H',
<br> 'I','J','K','L','M','N','O','P',
<br> 'Q','R','S','T','U','V','W','X',
<br> 'Y','Z','a','b','c','d','e','f',
<br> 'g','h','i','j','k','l','m','n',
<br> 'o','p','q','r','s','t','u','v',
<br> 'w','x','y','z','0','1','2','3',
<br> '4','5','6','7','8','9','+','/'
<br>);
<br>var reverseBase64Chars = new Array();
<br>for (var i=0; i < base64Chars.length; i++){
<br> reverseBase64Chars[base64Chars[i]] = i;
<br>}
<br>var base64Str;
<br>var base64Count;
<br>function setBase64Str(str){
<br> base64Str = str;
<br> base64Count = 0;
<br>}
<br>function readBase64(){
<br> if (!base64Str) return END_OF_INPUT;
<br> if (base64Count >= base64Str.length) return END_OF_INPUT;
<br> var c = base64Str.charCodeAt(base64Count) & 0xff;
<br> base64Count++;
<br> return c;
<br>}
<br>function encodeBase64(str){
<br> setBase64Str(str);
<br> var result = '';
<br> var inBuffer = new Array(3);
<br> var lineCount = 0;
<br> var done = false;
<br> while (!done && (inBuffer[0] = readBase64()) != END_OF_INPUT){
<br> inBuffer[1] = readBase64();
<br> inBuffer[2] = readBase64();
<br> result += (base64Chars[ inBuffer[0] >> 2 ]);
<br> if (inBuffer[1] != END_OF_INPUT){
<br> result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]);
<br> if (inBuffer[2] != END_OF_INPUT){
<br> result += (base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]);
<br> result += (base64Chars [inBuffer[2] & 0x3F]);
<br> } else {
<br> result += (base64Chars [((inBuffer[1] << 2) & 0x3c)]);
<br> result += ('=');
<br> done = true;
<br> }
<br> } else {
<br> result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30)]);
<br> result += ('=');
<br> result += ('=');
<br> done = true;
<br> }
<br> lineCount += 4;
<br> if (lineCount >= 76){
<br> result += ('
');
<br> lineCount = 0;
<br> }
<br> }
<br> return result;
<br>}
<br>function readReverseBase64(){
<br> if (!base64Str) return END_OF_INPUT;
<br> while (true){
<br> if (base64Count >= base64Str.length) return END_OF_INPUT;
<br> var nextCharacter = base64Str.charAt(base64Count);
<br> base64Count++;
<br> if (reverseBase64Chars[nextCharacter]){
<br> return reverseBase64Chars[nextCharacter];
<br> }
<br> if (nextCharacter == 'A') return 0;
<br> }
<br> return END_OF_INPUT;
<br>}
<br>function ntos(n){
<br> n=n.toString(16);
<br> if (n.length == 1) n="0"+n;
<br> n="%"+n;
<br> return unescape(n);
<br>}
<br>function decodeBase64(str){
<br> setBase64Str(str);
<br> var result = "";
<br> var inBuffer = new Array(4);
<br> var done = false;
<br> while (!done && (inBuffer[0] = readReverseBase64()) != END_OF_INPUT
<br> && (inBuffer[1] = readReverseBase64()) != END_OF_INPUT){
<br> inBuffer[2] = readReverseBase64();
<br> inBuffer[3] = readReverseBase64();
<br> result += ntos((((inBuffer[0] << 2) & 0xff)| inBuffer[1] >> 4));
<br> if (inBuffer[2] != END_OF_INPUT){
<br> result += ntos((((inBuffer[1] << 4) & 0xff)| inBuffer[2] >> 2));
<br> if (inBuffer[3] != END_OF_INPUT){
<br> result += ntos((((inBuffer[2] << 6) & 0xff) | inBuffer[3]));
<br> } else {
<br> done = true;
<br> }
<br> } else {
<br> done = true;
<br> }
<br> }
<br> return result;
<br>}
<br>var digitArray = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
<br>function toHex(n){
<br> var result = ''
<br> var start = true;
<br> for (var i=32; i>0;){
<br> i-=4;
<br> var digit = (n>>i) & 0xf;
<br> if (!start || digit != 0){
<br> start = false;
<br> result += digitArray[digit];
<br> }
<br> }
<br> return (result==''?'0':result);
<br>}
<br>function pad(str, len, pad){
<br> var result = str;
<br> for (var i=str.length; i<len; i++){
<br> result = pad + result;
<br> }
<br> return result;
<br>}
<br>function encodeHex(str){
<br> var result = "";
<br> for (var i=0; i<str.length; i++){
<br> result += pad(toHex(str.charCodeAt(i)&0xff),2,'0');
<br> }
<br> return result;
<br>}
<br>function decodeHex(str){
<br> str = str.replace(new RegExp("s/[^0-9a-zA-Z]//g"));
<br> var result = "";
<br> var nextchar = "";
<br> for (var i=0; i<str.length; i++){
<br> nextchar += str.charAt(i);
<br> if (nextchar.length == 2){
<br> result += ntos(eval('0x'+nextchar));
<br> nextchar = "";
<br> }
<br> }
<br> return result;
<br>}
<br>//-->
Base64 encode/decode was ported from a Java Base64 encoder/decoder.
Base64 encode/decode was ported to Macromedia Actionscript.
License
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU
General Public License for more details.
Copyright Stephen Ostermiller 2003-2006
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.