1111 * @param key - The encryption key, defaults to `'ryanuo'`.
1212 * @returns The XOR-transformed string.
1313 */
14- function xor ( str : string , key = 'ryanuo' ) {
14+ export function xor ( str : string , key = 'ryanuo' ) {
1515 return Array . from ( str )
1616 . map ( ( c , i ) =>
1717 String . fromCharCode ( c . charCodeAt ( 0 ) ^ key . charCodeAt ( i % key . length ) ) ,
@@ -31,7 +31,7 @@ function xor(str: string, key = 'ryanuo') {
3131 * @param key - Optional encryption key, defaults to `'ryanuo'`.
3232 * @returns The encrypted, URI-safe string.
3333 */
34- function encrypt ( str : string , key ?: string ) : string {
34+ export function encrypt ( str : string , key ?: string ) : string {
3535 return encodeURIComponent ( btoa ( xor ( str , key ) ) )
3636}
3737
@@ -46,7 +46,7 @@ function encrypt(str: string, key?: string): string {
4646 * @param str - The string to compress.
4747 * @returns The compressed, Base64-encoded string.
4848 */
49- function compress ( str : string ) : string {
49+ export function compress ( str : string ) : string {
5050 const bytes = new TextEncoder ( ) . encode ( str )
5151 const base64 = btoa ( String . fromCharCode ( ...bytes ) )
5252 return encodeURIComponent ( base64 )
@@ -63,7 +63,7 @@ function compress(str: string): string {
6363 * @param str - The compressed Base64 string.
6464 * @returns The original decompressed string.
6565 */
66- function decompress ( str : string ) : string {
66+ export function decompress ( str : string ) : string {
6767 try {
6868 const decodedBase64 = decodeURIComponent ( str )
6969 const binary = atob ( decodedBase64 )
@@ -90,7 +90,7 @@ function decompress(str: string): string {
9090 * @param key - Optional decryption key (must match the encryption key).
9191 * @returns The decrypted plain text string.
9292 */
93- function decrypt ( str : string , key ?: string ) : string {
93+ export function decrypt ( str : string , key ?: string ) : string {
9494 try {
9595 const decoded = atob ( decodeURIComponent ( str ) )
9696 return xor ( decoded , key )
@@ -100,11 +100,3 @@ function decrypt(str: string, key?: string): string {
100100 return ''
101101 }
102102}
103-
104- export {
105- xor ,
106- encrypt ,
107- decrypt ,
108- compress ,
109- decompress ,
110- }
0 commit comments