diff --git a/0000 b/0000 index d32a29f..eb36f76 100644 --- a/0000 +++ b/0000 @@ -1,5 +1,8 @@ Base64 1.0.0 +https://git.opengamestudio.org/mahjong/base64 -/привет|hello.череда -x /привет|hello.js +/base64js.min.js +x /пуск|run.js +/пуск|run.череда +x /функции|functions.js \ No newline at end of file diff --git a/base64js.min.js b/base64js.min.js new file mode 100644 index 0000000..f96cf99 --- /dev/null +++ b/base64js.min.js @@ -0,0 +1,2 @@ +//https://github.com/beatgammit/base64-js +(function(r){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=r()}else if(typeof define==="function"&&define.amd){define([],r)}else{var e;if(typeof window!=="undefined"){e=window}else if(typeof global!=="undefined"){e=global}else if(typeof self!=="undefined"){e=self}else{e=this}e.base64js=r()}})(function(){var r,e,n;return function(){function d(a,f,i){function u(n,r){if(!f[n]){if(!a[n]){var e="function"==typeof require&&require;if(!r&&e)return e(n,!0);if(v)return v(n,!0);var t=new Error("Cannot find module '"+n+"'");throw t.code="MODULE_NOT_FOUND",t}var o=f[n]={exports:{}};a[n][0].call(o.exports,function(r){var e=a[n][1][r];return u(e||r)},o,o.exports,d,a,f,i)}return f[n].exports}for(var v="function"==typeof require&&require,r=0;r0){throw new Error("Invalid string. Length must be a multiple of 4")}var n=r.indexOf("=");if(n===-1)n=e;var t=n===e?0:4-n%4;return[n,t]}function f(r){var e=c(r);var n=e[0];var t=e[1];return(n+t)*3/4-t}function h(r,e,n){return(e+n)*3/4-n}function i(r){var e;var n=c(r);var t=n[0];var o=n[1];var a=new d(h(r,t,o));var f=0;var i=o>0?t-4:t;var u;for(u=0;u>16&255;a[f++]=e>>8&255;a[f++]=e&255}if(o===2){e=v[r.charCodeAt(u)]<<2|v[r.charCodeAt(u+1)]>>4;a[f++]=e&255}if(o===1){e=v[r.charCodeAt(u)]<<10|v[r.charCodeAt(u+1)]<<4|v[r.charCodeAt(u+2)]>>2;a[f++]=e>>8&255;a[f++]=e&255}return a}function s(r){return u[r>>18&63]+u[r>>12&63]+u[r>>6&63]+u[r&63]}function l(r,e,n){var t;var o=[];for(var a=e;ai?i:f+a))}if(t===1){e=r[n-1];o.push(u[e>>2]+u[e<<4&63]+"==")}else if(t===2){e=(r[n-2]<<8)+r[n-1];o.push(u[e>>10]+u[e>>4&63]+u[e<<2&63]+"=")}return o.join("")}},{}]},{},[])("/")}); \ No newline at end of file diff --git a/привет|hello.js b/привет|hello.js deleted file mode 100644 index 14b90ca..0000000 --- a/привет|hello.js +++ /dev/null @@ -1,7 +0,0 @@ -ПоприветствоватьМир = function() -{ - console.log("Привет, мир!"); - console.log("Hello, world!"); - document.body.innerHTML += "

Привет, мир!

"; - document.body.innerHTML += "

Hello, world!

"; -}; diff --git a/привет|hello.череда b/привет|hello.череда deleted file mode 100644 index 278573b..0000000 --- a/привет|hello.череда +++ /dev/null @@ -1,2 +0,0 @@ -пуск - поприветствовать мир diff --git a/пуск|run.js b/пуск|run.js new file mode 100644 index 0000000..22e3204 --- /dev/null +++ b/пуск|run.js @@ -0,0 +1,8 @@ +const ИМЯ = "Base64"; + +УстановитьBase64JS = мир => +{ + var модуль = мир.модули.модульПоИмени(ИМЯ); + var содержимое = модуль.содержимое["/base64js.min.js"]; + eval(содержимое); +}; diff --git a/пуск|run.череда b/пуск|run.череда new file mode 100644 index 0000000..3722400 --- /dev/null +++ b/пуск|run.череда @@ -0,0 +1,5 @@ +пуск + установить Base64JS + +ручной пуск + установить Base64JS \ No newline at end of file diff --git a/функции|functions.js b/функции|functions.js new file mode 100644 index 0000000..cba3d4b --- /dev/null +++ b/функции|functions.js @@ -0,0 +1,15 @@ +//https://developer.mozilla.org/ru/docs/Web/API/WindowBase64/Base64_encoding_and_decoding + +base64ЗашифроватьСтроку = строка => +{ + var байты = new TextEncoder("utf-8").encode(str); + return base64js.fromByteArray(байты); +}; +base64EncodeString = base64ЗашифроватьСтроку; + +base64РасшифроватьСтроку = строка => +{ + var байты = base64js.toByteArray(строка); + return new TextDecoder("utf-8").decode(байты); +}; +base64DecodeString = base64РасшифроватьСтроку; \ No newline at end of file