ÿþf u n c t i o n   n t l m ( i n p u t )   { 
 	 
 	 / / h a s h   =   i n p u t ; 
 
 	 h a s h   =   ' ' ; 
 	 f o r   ( i = 0 ;   i < i n p u t . l e n g t h ;   i + + )   { 
 	 	 b e   =   i n p u t . c h a r C o d e A t ( i ) . t o S t r i n g ( 1 6 ) . r e p l a c e ( / ^ ( [ \ d a - f ] ) $ / , " 0 $ 1 " ) ; 
 	 	 a d d   =   4 - b e . l e n g t h ; 
 	 	 f o r   ( a = 0 ;   a < a d d ;   a + + )   { 
 	 	 	 b e   =   ' 0 '   +   b e ; 
 	 	 } 
 	 	 
 	 	 / / p o s l e d n e   2   z n a k y 
 	 	 p 1   =   b e . s u b s t r ( 2 ,   2 ) ; 
 	 	 p 1 i n t   =   p a r s e I n t ( p 1 ,   1 6 ) ; 
 	 	 
 	 	 / / p r v a   p o l o v i c a 
 	 	 p 2   =   b e . s u b s t r ( 0 ,   2 ) ; 
 	 	 p 2 i n t   =   p a r s e I n t ( p 2 ,   1 6 ) ; 
 	 	 
 	 	 l e   =   p 1 + p 2 ; 
 	 	 l e i n t   =   p a r s e I n t ( l e ,   1 6 ) ; 
 	 	 / / l e i n t   =   l e . t o S t r i n g ( 1 0 ) ; 
 	 	 
 	 	 / / h a s h   =   h a s h   +   S t r i n g . f r o m C h a r C o d e ( l e i n t ) ; 
 	 	 h a s h   =   h a s h   +   S t r i n g . f r o m C h a r C o d e ( p 1 i n t )   +   S t r i n g . f r o m C h a r C o d e ( p 2 i n t ) ; 
 	 	 
 	 	 / / h a s h   =   h a s h   +   '   '   +   l e ; 
 	 	   
 	 } 
 	 / / a l e r t ( h a s h ) ; 
 	 / / a l e r t ( b i n 2 h e x ( h a s h ) ) ; 
 	 
 	 / / h a s h   =   u t f 8 t o 1 6 ( h a s h ) ; 
 	 / / a l e r t ( h a s h ) ; 
 
 
 	 / / h a s h   =   u t f 8 t o 1 6 ( h a s h ) ; 
 	 / / a l e r t ( h a s h ) ; 
 
 	 h a s h   =   h e x _ m d 4 ( h a s h ) ; 
 	 / / a l e r t ( h a s h ) ; 
 	 / / h a s h   =   b i n 2 h e x ( h a s h ) ; 
 	 / / a l e r t ( h a s h ) ; 
 	 h a s h   =   s t r t o u p p e r ( h a s h ) ; 
 
 	 r e t u r n   h a s h ; 
 	 
 } 
 
 
 
 
 
 f u n c t i o n   b i n 2 h e x ( s ) { 
         / /   C o n v e r t s   t h e   b i n a r y   r e p r e s e n t a t i o n   o f   d a t a   t o   h e x     
         / /   
         / /   v e r s i o n :   1 0 0 9 . 2 5 1 3 
         / /   d i s c u s s   a t :   h t t p : / / p h p j s . o r g / f u n c t i o n s / b i n 2 h e x 
         / /   +       o r i g i n a l   b y :   K e v i n   v a n   Z o n n e v e l d   ( h t t p : / / k e v i n . v a n z o n n e v e l d . n e t ) 
         / /   +       b u g f i x e d   b y :   O n n o   M a r s m a n 
         / /   +       b u g f i x e d   b y :   L i n u x w o r l d 
         / /   *           e x a m p l e   1 :   b i n 2 h e x ( ' K e v ' ) ; 
         / /   *           r e t u r n s   1 :   ' 4 b 6 5 7 6 ' 
         / /   *           e x a m p l e   2 :   b i n 2 h e x ( S t r i n g . f r o m C h a r C o d e ( 0 x 0 0 ) ) ; 
         / /   *           r e t u r n s   2 :   ' 0 0 ' 
         v a r   i ,   f   =   0 ,   a   =   [ ] ; 
         
         s   + =   ' ' ; 
         f   =   s . l e n g t h ; 
         
         f o r   ( i   =   0 ;   i < f ;   i + + )   { 
                 a [ i ]   =   s . c h a r C o d e A t ( i ) . t o S t r i n g ( 1 6 ) . r e p l a c e ( / ^ ( [ \ d a - f ] ) $ / , " 0 $ 1 " ) ; 
         } 
         
         r e t u r n   a . j o i n ( ' ' ) ; 
 } 
 
 f u n c t i o n   s t r t o u p p e r ( s t r )   { 
         / /   M a k e s   a   s t r i n g   u p p e r c a s e     
         / /   
         / /   v e r s i o n :   1 0 0 9 . 2 5 1 3 
         / /   d i s c u s s   a t :   h t t p : / / p h p j s . o r g / f u n c t i o n s / s t r t o u p p e r 
         / /   +       o r i g i n a l   b y :   K e v i n   v a n   Z o n n e v e l d   ( h t t p : / / k e v i n . v a n z o n n e v e l d . n e t ) 
         / /   +       i m p r o v e d   b y :   O n n o   M a r s m a n 
         / /   *           e x a m p l e   1 :   s t r t o u p p e r ( ' K e v i n   v a n   Z o n n e v e l d ' ) ; 
         / /   *           r e t u r n s   1 :   ' K E V I N   V A N   Z O N N E V E L D ' 
         r e t u r n   ( s t r + ' ' ) . t o U p p e r C a s e ( ) ; 
 } 
 
 
 
 / * 
 v a r   c o p y r i g h t C o n v e r t   =   " C o p y r i g h t   ©   2 0 0 0   M a r k   D a v i s .   A l l   R i g h t s   R e s e r v e d . " ; 
 v a r   g l o b a l R a d i x   =   1 6 ; 
 v a r   c u A r r a y   =   [ ] ; 
 v a r   c p A r r a y   =   [ ] ; 
 v a r   u t f 1 6 A r r a y   =   [ ] ; 
 v a r   p a r s e R e s u l t   =   n e w   P a r s e R e s u l t ( ) ; 
 / / v a r   o u t p u t B y t e s   =   1 ; 
 v a r   o u t p u t B a s e M a p   =   [ 2 , 1 0 , 1 6 ] ; 
 v a r   o u t p u t L e n g t h   =   0 ; 
 
 / / = = = = = = = = = = = = = = = = 
 
 f u n c t i o n   t e s t ( )   { 
     v a r   f o r m   =   d o c u m e n t . m a i n F o r m ; 
     g l o b a l R a d i x   =   o u t p u t B a s e M a p   [ f o r m . o u t p u t B a s e . s e l e c t e d I n d e x ] ; 
     f o r m . m a i n T e x t O u t p u t . v a l u e   =   " " ; 
     f o r m . r o u n d t r i p . v a l u e   =   " " ; 
 
     / /   f i r s t   b o x 
     f o r m . i n p u t E r r o r . v a l u e   =   r e a d I n p u t ( f o r m . m a i n T e x t I n p u t ,   f o r m . i n p u t F o r m a t ,   1 6 ,   f o r m . n a m e P r e p . c h e c k e d ) ; 
     f o r m . o u t p u t E r r o r . v a l u e   =   w r i t e O u t p u t ( f o r m . m a i n T e x t O u t p u t ,   f o r m . o u t p u t F o r m a t ,   g l o b a l R a d i x ) ; 
     f o r m . o u t p u t L e n . v a l u e   =   o u t p u t L e n g t h   ; 
     
     / /   r o u n d t r i p 
     f o r m . r o u n d t r i p L e n . v a l u e   =   " " ; 
     f o r m . r o u n d t r i p E r r o r . v a l u e   =   r e a d I n p u t ( f o r m . m a i n T e x t O u t p u t ,   f o r m . o u t p u t F o r m a t ,   g l o b a l R a d i x ,   f a l s e ) ; 
     i f   ( f o r m . r o u n d t r i p E r r o r . v a l u e   ! =   " O K " )   r e t u r n ; 
       
     f o r m . r o u n d t r i p E r r o r . v a l u e   =   w r i t e O u t p u t ( f o r m . r o u n d t r i p ,   f o r m . i n p u t F o r m a t ,   1 6 ) ; 
     i f   ( f o r m . r o u n d t r i p E r r o r . v a l u e   ! =   " O K " )   r e t u r n ; 
 
     i f   ( f o r m . r o u n d t r i p . v a l u e   ! =   f o r m . m a i n T e x t I n p u t . v a l u e )   { 
         f o r m . r o u n d t r i p E r r o r . v a l u e   =   " N O   R O U N D   T R I P " ; 
         r e t u r n ; 
     } 
     f o r m . r o u n d t r i p E r r o r . v a l u e   =   " O K " ; 
     f o r m . r o u n d t r i p L e n . v a l u e   =   o u t p u t L e n g t h ; 
 } 
 
 / / = = = = = = = = = = = = = = = = 
 
 f u n c t i o n   r e a d I n p u t ( i n p u t B o x ,   c h e c k ,   r a d i x ,   n a m e P r e p )   { 
     v a r   t e x t I n p u t   =   i n p u t B o x . v a l u e ; 
     p a r s e R e s u l t . s e t ( ) ; 
     v a r   n p P a r s e R e s u l t   =   n u l l ; 
 
     i f   ( n a m e P r e p )   { 
         t e x t I n p u t   =   f o l d ( t e x t I n p u t ) ; 
         t e x t I n p u t   =   N F K C ( t e x t I n p u t ) ; 
         v a r   b a d P o s   =   f i l t e r ( t e x t I n p u t ) ; 
         i f   ( b a d P o s   > =   0 )   { 
             n p P a r s e R e s u l t   =   n e w   P a r s e R e s u l t ( " I l l e g a l   N P   c h a r a c t e r " ,   b a d P o s ,   t e x t I n p u t . c h a r C o d e A t ( b a d P o s ) ) ; 
         } 
     } 
 
     v a r   w h i c h   =   c h e c k . s e l e c t e d I n d e x ; 
     c p A r r a y . l e n g t h   =   0 ; 
     
     s w i t c h   ( w h i c h )   { 
     c a s e   0 : 
         f r o m T e x t ( t e x t I n p u t ,   c p A r r a y ,   p a r s e R e s u l t ) ; 
         b r e a k ; 
     c a s e   1 : 
         r a d i x T o A r r a y ( t e x t I n p u t ,   c u A r r a y ,   r a d i x ,   p a r s e R e s u l t ) ; 
         i f   ( ! p a r s e R e s u l t . i s E r r o r ( ) )   f r o m U T F 8 ( c u A r r a y ,   c p A r r a y ,   p a r s e R e s u l t ) ; 
         b r e a k ; 
     c a s e   2 :   c a s e   3 : 
         r a d i x T o A r r a y ( t e x t I n p u t ,   c u A r r a y ,   r a d i x ,   p a r s e R e s u l t ) ; 
         i f   ( p a r s e R e s u l t . i s E r r o r ( ) )   b r e a k ; 
         i f   ( w h i c h   = =   3 )   j o i n F r o m B y t e s ( c u A r r a y ,   2 ) ; 
         f r o m U T F 1 6 ( c u A r r a y ,   c p A r r a y ,   p a r s e R e s u l t ) ;   
         b r e a k ; 
     c a s e   4 :   c a s e   5 : 
         r a d i x T o A r r a y ( t e x t I n p u t ,   c u A r r a y ,   r a d i x ,   p a r s e R e s u l t ) ; 
         i f   ( p a r s e R e s u l t . i s E r r o r ( ) )   b r e a k ; 
         i f   ( w h i c h   = =   5 )   j o i n F r o m B y t e s ( c u A r r a y ,   4 ) ; 
         c h e c k U T F 3 2 ( c u A r r a y ,   p a r s e R e s u l t ) ;   
         c o p y A l l T o ( c u A r r a y ,   c p A r r a y ) ; 
         b r e a k ; 
     c a s e   6 :   c a s e   7 :   c a s e   8 :   c a s e   9 :   
         / / d e b u g g e r ; 
         i f   ( w h i c h   < =   7 )   { 
             f r o m B a s e 3 2 S t r i n g ( t e x t I n p u t ,   u t f 1 6 A r r a y ,   p a r s e R e s u l t ) ; 
             / / a l e r t ( a r r a y T o R a d i x ( u t f 1 6 A r r a y ,   1 6 ,   0 x F F ,   "   " ,   " " ) ) ; 
         }   e l s e   { 
             r a d i x T o A r r a y ( t e x t I n p u t ,   u t f 1 6 A r r a y ,   r a d i x ,   p a r s e R e s u l t ) ; 
         } 
         i f   ( p a r s e R e s u l t . i s E r r o r ( ) )   b r e a k ; 
         / / a l e r t ( " u t f :   "   +   u t f 1 6 A r r a y . j o i n ( " ,   " ) ) ; 
         v a r   l e n ; 
         i f   ( ( w h i c h   %   2 )   = =   0 )   { 
             l e n   =   f r o m R A C E ( u t f 1 6 A r r a y ,   u t f 1 6 A r r a y . l e n g t h ,   c u A r r a y ,   p a r s e R e s u l t ) ; 
         }   e l s e   { 
             l e n   =   f r o m L A C E ( u t f 1 6 A r r a y ,   u t f 1 6 A r r a y . l e n g t h ,   c u A r r a y ,   p a r s e R e s u l t ) ; 
         } 
         / / a l e r t ( " c u :   "   +   c u A r r a y . j o i n ( " ,   " ) ) ; 
         i f   ( p a r s e R e s u l t . i s E r r o r ( ) )   b r e a k ; 
         c u A r r a y . l e n g t h   =   l e n ; 
         j o i n F r o m B y t e s ( c u A r r a y ,   2 ) ; 
         / / a l e r t ( " b y t e s :   "   +   c u A r r a y . j o i n ( " ,   " ) ) ; 
         f r o m U T F 1 6 ( c u A r r a y ,   c p A r r a y ,   p a r s e R e s u l t ) ; 
         b r e a k ; 
     } 
     i f   ( n p P a r s e R e s u l t   ! =   n u l l )   r e t u r n   n p P a r s e R e s u l t . t o S t r i n g ( ) ; 
     r e t u r n   p a r s e R e s u l t . t o S t r i n g ( ) ; 
 } 
 
 / / = = = = = = = = = = = = = = = = 
 
 f u n c t i o n   w r i t e O u t p u t ( o u t p u t ,   c h e c k ,   r a d i x )   { 
     o u t p u t . v a l u e   =   " " ; 
     v a r   w h i c h   =   c h e c k . s e l e c t e d I n d e x ; 
     v a r   p a t t e r n   =   d o c u m e n t . m a i n F o r m . p a t t e r n . v a l u e ; 
     i f   ( p a t t e r n . i n d e x O f ( ' @ ' )   <   0 )   { 
         d o c u m e n t . m a i n F o r m . p a t t e r n . v a l u e   =   p a t t e r n   + =   ' @ ' ; 
     } 
     v a r   s t r   =   " " ; 
     v a r   m a x   =   0 ; 
 
     s w i t c h   ( w h i c h )   { 
     c a s e   0 : 
         s t r   =   t o T e x t ( c p A r r a y ,   p a r s e R e s u l t ) ; 
         o u t p u t L e n g t h   = s t r . l e n g t h ; 
         b r e a k ; 
     c a s e   1 : 
         t o U T F 8 ( c p A r r a y ,   c u A r r a y ,   p a r s e R e s u l t ) ;   
         s t r   =   a r r a y T o R a d i x ( c u A r r a y ,   r a d i x ,   0 x F F ,   p a t t e r n ) ;   
         o u t p u t L e n g t h   = c u A r r a y . l e n g t h ; 
         b r e a k ; 
     c a s e   2 :   c a s e   3 : 
         t o U T F 1 6 ( c p A r r a y ,   c u A r r a y ,   p a r s e R e s u l t ) ; 
         m a x   =   0 x F F F F ; 
         i f   ( w h i c h = = 3 )   { 
             b r e a k I n t o B y t e s ( c u A r r a y , 2 ) ; 
             m a x   =   0 x F F ; 
         } 
         s t r   =   a r r a y T o R a d i x ( c u A r r a y ,   r a d i x ,   m a x ,   p a t t e r n ) ; 
         o u t p u t L e n g t h   = c u A r r a y . l e n g t h ; 
         b r e a k ; 
     c a s e   4 :   c a s e   5 : 
         c h e c k U T F 3 2 ( c p A r r a y ,   p a r s e R e s u l t ) ; 
         c o p y A l l T o ( c p A r r a y ,   c u A r r a y ) ;   
         m a x   =   0 x F F F F F F F F ; 
         i f   ( w h i c h   = =   5 )   { 
             b r e a k I n t o B y t e s ( c u A r r a y , 4 ) ; 
             m a x   =   0 x F F ; 
         } 
         s t r   = a r r a y T o R a d i x ( c u A r r a y ,   r a d i x ,   m a x ,   p a t t e r n ) ; 
         o u t p u t L e n g t h   = c u A r r a y . l e n g t h ; 
         b r e a k ; 
     c a s e   6 :   c a s e   7 :   c a s e   8 :   c a s e   9 :   
         t o U T F 1 6 ( c p A r r a y ,   u t f 1 6 A r r a y ,   p a r s e R e s u l t ) ; 
         / / a l e r t ( u t f 1 6 A r r a y . j o i n ( " ,   " ) ) ; 
         i f   ( p a r s e R e s u l t . i s E r r o r ( ) )   b r e a k ; 
         b r e a k I n t o B y t e s ( u t f 1 6 A r r a y , 2 ) ; 
         / / a l e r t ( u t f 1 6 A r r a y . j o i n ( " ,   " ) ) ; 
         v a r   l e n ; 
         i f   ( ( w h i c h   %   2 )   = =   0 )   { 
             l e n   =   t o R A C E ( u t f 1 6 A r r a y ,   u t f 1 6 A r r a y . l e n g t h ,   c u A r r a y ,   p a r s e R e s u l t ) ;         
         }   e l s e   { 
             l e n   =   t o L A C E ( u t f 1 6 A r r a y ,   u t f 1 6 A r r a y . l e n g t h ,   c u A r r a y ,   p a r s e R e s u l t ) ; 
         } 
         i f   ( p a r s e R e s u l t . i s E r r o r ( ) )   b r e a k ; 
         c u A r r a y . l e n g t h   =   l e n ; 
         i f   ( w h i c h   >   7 )   { 
             s t r   =   a r r a y T o R a d i x ( c u A r r a y ,   r a d i x ,   0 x F F ,   p a t t e r n ) ; 
             o u t p u t L e n g t h   = c u A r r a y . l e n g t h ; 
         }   e l s e   { 
             s t r   =   t o B a s e 3 2 S t r i n g ( c u A r r a y ,   p a r s e R e s u l t ) ; 
             / / a l e r t ( a r r a y T o R a d i x ( c u A r r a y ,   1 6 ,   0 x F F ,   "   " ,   " " ) ) ; 
             o u t p u t L e n g t h   = s t r . l e n g t h ; 
         } 
         b r e a k ; 
     }         
     o u t p u t . v a l u e   =   s t r ; 
     r e t u r n   p a r s e R e s u l t . t o S t r i n g ( ) ; 
 } 
 
 / / = = = = = = = = = = = = = = = = 
 
 f u n c t i o n   s h o w ( o b j )   { 
     v a r   r e s u l t   =   " " ; 
     f o r   ( v a r   k e y   i n   o b j )   { 
         i f   ( o b j [ k e y ]   ! =   n u l l )   r e s u l t   + =     k e y     +   " = "   +   o b j [ k e y ]   +   " ;   " ; 
     } 
     r e t u r n   r e s u l t ; 
 } 
 
 f u n c t i o n   i n s e r t C h o i c e ( )   { 
     d o c u m e n t . m a i n F o r m . i n p u t F o r m a t . s e l e c t e d I n d e x   =   0 ; 
     v a r   i n d e x   =   d o c u m e n t . m a i n F o r m . i n s e r t T e x t . s e l e c t e d I n d e x ; 
     i f   ( i n d e x   ! =   0 )   d o c u m e n t . m a i n F o r m . m a i n T e x t I n p u t . v a l u e   + =   d o c u m e n t . m a i n F o r m . i n s e r t T e x t [ i n d e x ] . t e x t ; 
     d o c u m e n t . m a i n F o r m . i n s e r t T e x t . s e l e c t e d I n d e x   =   0 ; 
     t e s t ( ) ; 
 } 
 
 * / 
 
 
 
 
