1export function md5(input) {
2/*
3* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
16var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
17/*
18* These are the functions you'll usually want to call
19* They take string arguments and return either hex or base-64 encoded strings
20*/
21function hex_md5(s) {
22return binl2hex(core_md5(str2binl(s), s.length * chrsz));
23}
24function b64_md5(s) {
25return binl2b64(core_md5(str2binl(s), s.length * chrsz));
26}
27function str_md5(s) {
28return binl2str(core_md5(str2binl(s), s.length * chrsz));
29}
30function hex_hmac_md5(key, data) {
31return binl2hex(core_hmac_md5(key, data));
32}
33function b64_hmac_md5(key, data) {
34return binl2b64(core_hmac_md5(key, data));
35}
36function str_hmac_md5(key, data) {
37return binl2str(core_hmac_md5(key, data));
38}
40* Perform a simple self-test to see if the VM is working
41*/
42function md5_vm_test() {
43return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
44}
46* Calculate the MD5 of an array of little-endian words, and a bit length
47*/
48function core_md5(x, len) {
49/* append padding */
50x[len >> 5] |= 0x80 << ((len) % 32);
131}
132/*
133* These functions implement the four basic operations the algorithm uses.
134*/
135function md5_cmn(q, a, b, x, s, t) {
136return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
137}
138function md5_ff(a, b, c, d, x, s, t) {
139return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
140}
141function md5_gg(a, b, c, d, x, s, t) {
142return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
143}
144function md5_hh(a, b, c, d, x, s, t) {
145return md5_cmn(b ^ c ^ d, a, b, x, s, t);
146}
147function md5_ii(a, b, c, d, x, s, t) {
148return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
149}
151* Calculate the HMAC-MD5, of a key and some data
152*/
153function core_hmac_md5(key, data) {
154var bkey = str2binl(key);
155if (bkey.length > 16)
167* to work around bugs in some JS interpreters.
168*/
169function safe_add(x, y) {
170var lsw = (x & 0xFFFF) + (y & 0xFFFF);
171var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
175* Bitwise rotate a 32-bit number to the left.
176*/
177function bit_rol(num, cnt) {
178return (num << cnt) | (num >>> (32 - cnt));
179}
182* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
183*/
184function str2binl(str) {
185var bin = Array();
186var mask = (1 << chrsz) - 1;
192* Convert an array of little-endian words to a string
193*/
194function binl2str(bin) {
195var str = "";
196var mask = (1 << chrsz) - 1;
202* Convert an array of little-endian words to a hex string.
203*/
204function binl2hex(binarray) {
205var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
206var str = "";
214* Convert an array of little-endian words to a base-64 string
215*/
216function binl2b64(binarray) {
217var tab =
218"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
addCommentmain.tsx1 match
3import { commentsDB } from "https://esm.town/v/vez/commentsDB";
45export async function addComment(str) {
6commentsDB.push(str);
7await set("commentsDB", commentsDB);
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
34export function comments({ token, since, until, offset, limit, relationship }: {
5token: string;
6since?: Date;
4import { dalleImageUrl } from "https://esm.town/v/andreterron/dalleImageUrl";
56export async function dallemail(email) {
7let imageUrl = await dalleImageUrl(email.text);
8return email2({
actuallyItsXBotmain.tsx1 match
4import { refreshActuallyBotToken } from "https://esm.town/v/andreterron/refreshActuallyBotToken";
56export async function actuallyItsXBot() {
7const token = await refreshActuallyBotToken();
8//
feedGeneratormain.tsx2 matches
29cursor?: string;
30}
31export async function feedGenerator({ feed, serviceDID, publisherDID, hostname }: {
32serviceDID?: string;
33publisherDID: string;
57return [q.toString()];
58};
59return async function (req: express.Request, res: express.Response) {
60const serviceDid = serviceDID ?? `did:web:${hostname}`;
61const didCache = new resolver.MemoryCache();
chatSampleFunctionMultiplemain.tsx7 matches
2import { chat } from "https://esm.town/v/webup/chat";
34export const chatSampleFunctionMultiple = (async () => {
5// Helper function to call and print assistant response
6const callAssistant = async (messages) => {
7const response = await chat(messages, {
8functions: schemasWeather,
9});
10typeof response === "object"
18role: "system",
19content:
20"Don't make assumptions about what values to plug into functions. Ask for clarification if a user request is ambiguous.",
21},
22{ role: "user", content: "What's the weather like today" },
23];
24let response = await callAssistant(messages);
25// Once we provide the missing info, it will generate the appropriate function arguments
26messages.push({ role: "assistant", content: response });
27messages.push({ role: "user", content: "I'm in Glasgow, Scotland." });
28response = await callAssistant(messages);
29// By prompting it differently, we can get it to target the other function we've told
30messages.length = 1;
31messages.push({
35});
36response = await callAssistant(messages);
37// Let's provide the num of days, and model will generate the call to the other function
38messages.push({ role: "assistant", content: response });
39messages.push({ role: "user", content: "5 days" });
1export function greet(name: string) {
2name = name || "world";
3return "Hello, " + name + "!";
blogRSSTrackermain.tsx1 match
7import { parseXML } from "https://esm.town/v/stevekrouse/parseXML?v=1";
89export async function blogRSSTracker() {
10// gets newest blog from rss feed
11const blogRSSLink = "https://posthog.com/rss.xml";