문제

Lyris ListManager (10.2)에 사용자 정의를 작성하려고합니다. 언어는 TCL입니다. 값을 Base64 (또는 실제로 쿼리 스트링 매개 변수를 난독 화하는 모든 것)로 인코딩해야하지만 방법을 알아낼 수는 없습니다. 이 작업을 수행하기 위해 TCL 출신의 명령이 있습니까?

도움이 되었습니까?

해결책

Base64 패키지를 사용하려면 문제에 따라이 작은 Procs를 사용하여 데이터를 16 진수로 변환 할 수 있습니다. tcl> 8이 필요합니다

proc BIN2HEX { text }   { binary scan $text H* result; return $result }
proc HEX2BIN { hex }    { return [binary format H* $hex] }
set hex [BIN2HEX $yourText]
set textAgain [HEX2BIN $hex]

실제로 Base64가 필요한 경우 tcllib 분포에서 전체 Base64 파일을 복사/붙여 넣을 수 있습니다. http://sourceforge.net/projects/tcllib/files/tcllib/1.11.1/ 코드에 ( "패키지 제공"라인 제거)

다른 팁

의 존재 http://tcllib.sourceforge.net/doc/base64.html 기본 기능이 없다는 것을 나타내는 것 같습니다. 소스를 복사하여 수정에 추가 할 수 있습니다.

% base64::encode "Hello, world"
SGVsbG8sIHdvcmxk

% base64::encode [string repeat xyz 20]
eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6
eHl6eHl6eHl6
% base64::encode -wrapchar "" [string repeat xyz 20]
eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6

# NOTE: base64 encodes BINARY strings.
% set chemical [encoding convertto utf-8 "C\u2088H\u2081\u2080N\u2084O\u2082"]
% set encoded [base64::encode $chemical]
Q+KCiEjigoHigoBO4oKET+KCgg==
% set caffeine [encoding convertfrom utf-8 [base64::decode $encoded]]

TCL 라이브러리 (패키지/모듈)를 환경에로드 할 수있는 기능이있는 경우 tcllib 구현. 그것이 Vinko Vrsalovic이 그의 응답에서 명령을 보여준 것입니다.

% package require base64
2.4
% base64::encode bob
Ym9i

16 진수로 인코딩하기에 충분하다면 이진 다음과 같이 명령 :

% set query "Hello, world"
Hello, world
% binary scan $query H* hexquery
1
% puts $hexquery
48656c6c6f2c20776f726c64
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top