Update
This commit is contained in:
parent
b82dd9c6da
commit
c863684c6d
10 changed files with 1856 additions and 1736 deletions
|
@ -152,4 +152,6 @@ Watch out for **operator precedence**! C infamously has weird precedence with so
|
|||
|
||||
Watch out for **[macro](macro.md) arguments**, always bracket them because they get substituted on text level. Consider e.g. a macro `#define divide(a,b) a / b`, and then doing `divide(3 + 1,2)` -- this gets expanded to `3 + 1 / 2` while you probably wanted `(3 + 1) / 2`, i.e. the macro should have been defined as `#define divide(a,b) (a) / (b)`.
|
||||
|
||||
This may get some beginners: `for (unsigned char i = 0; i < 256; ++i) { ... }` -- this loop will never end because the data type is not big enough to surpass the iteration limit. Similarly this may happen if you use e.g. unsigned int and 65536 and so on. New compilers will warn you about this.
|
||||
|
||||
This is not really a pitfall, rather a headscratcher, but don't forget to link math library with `-lm` flag when using using the `math.h` library.
|
10
exercises.md
10
exercises.md
|
@ -153,7 +153,9 @@ Bear in mind the main purpose of this quiz is for you to test your understanding
|
|||
50. Is [LGBT](lgbt.md) [good](good.md)?
|
||||
51. Write a [C](c.md) function in 60 characters or fewer that takes a string (`char *`, consider zero terminated ASCII string) and replaces all semicolons in it with colons (`;` -> `:`). It can return nothing (`void`).
|
||||
52. Order the following [people](people.md) by date of their birth from oldest: [Alan Turing](turing.md), Caesar, [Buddha](buddha.md) (Siddhartha Gautama), Johannes Gutenberg, Aristotle, [Charles Babbage](babbage.md), [Linus Torvalds](torvalds.md), [Jesus](jesus.md), [Adolf Hitler](hitler.md), Muhammad (prophet of Islam), [Albert Einstein](einstein.md), [Richard Stallman](rms.md), Napoleon, Leonardo da Vinci, [Karl Marx](marx.md).
|
||||
53. Did you enjoy this quiz?
|
||||
53. State at least 5 reasons for why [Rust](rust.md) sucks so much.
|
||||
54. Find at least one function *f(x)* that's defined for all non-negative integers and for which it holds that *x + f(x) - f(x + 1) = 0*. (It's enough if you show a sequence of numbers with obvious continuation.)
|
||||
55. Did you enjoy this quiz?
|
||||
|
||||
### Answers
|
||||
|
||||
|
@ -166,7 +168,7 @@ Bear in mind the main purpose of this quiz is for you to test your understanding
|
|||
7. The relationship is commonly described like this: information is interpreted data. I.e. data is just a sequence of symbols, information is the knowledge we extract from it.
|
||||
8. The probability of program breaking is 1 minus probability of it not breaking. For a program to NOT break during one year, all libraries have to stay unchanged (probability 0.95 for each one): that's 0.95 * 0.95 * 0.95 * ... = 0.95^10. Similarly the probability of it not breaking during 5 years is (0.95^10)^5, so the probability of the program breaking in 5 years is around 92%.
|
||||
9. `e`
|
||||
10. Original Unix (around 1970), MS DOS (1981), Windows (1985), Linux (1998), TempleOS (2007). Linux stands out because it's not an operating system, it's a kernel.
|
||||
10. Original Unix (around 1970), MS DOS (1981), Windows (1985), Linux (1998), TempleOS (2007). Linux stands out because it's not an operating system, it's a kernel (alternative answers are possible, for example TempleOS is the only software here developed by a single man).
|
||||
11. 80085
|
||||
12. third
|
||||
13. *2 * N*. We can multiply the greatest values: *(2^N - 1) * (2^N - 1) = 2^(2 * N) - 2^(N + 1) + 1*; The greatest term *2^(2 * N)* in binary is 1 with *2 * N* zeros after it, subtracting *(2^(N + 1) - 1)* will always definitely shorten this number by at least one bit (1000... minus anything non-zero will shorten the number). So at most we will need *2 * N* bits for the result, but we can't use fewer because for example 11 * 11 = 1001 -- in this case fewer than 2 * 2 = 4 bits wouldn't suffice. So in general we need *2 * N* bits.
|
||||
|
@ -209,7 +211,9 @@ Bear in mind the main purpose of this quiz is for you to test your understanding
|
|||
50. hell no
|
||||
51. For example: `void r(char *s) { while (*s) s += (*s -= *s == ';') != 0; }`;
|
||||
52. Buddha (< -480), Diogenes (-404), Aristotle (-384), Caesar (-100), Jesus (around -5), Muhammad (around 570), Gutenberg (around 1400), Da Vinci (1452), Napoleon (1769), Babbage (1791), Marx (1818), Einstein (1879), Hitler (1889), Turing (1912), Stallman (1953), Torvalds (1969).
|
||||
53. yes
|
||||
53. For example: it's bloated, slow, can't be compiled on good computers, it's tranny software with toxic fascist community, it has issues with legal freedom (trademarks), it has [code of censorship](coc.md), it has no specification, it's obsessed with "safety", the name is complete shit, it is associated with [corporations](corporation.md), has some abomination of [OOP](oop.md), it's littered with dependencies, it's [capitalist monopoly software](capitalist_software.md), it's trying to display [C](c.md), it is hosted on [GitHub](github.md), the users are and devs idiots and so on and so forth.
|
||||
54. We can rewrite the condition as *f(x + 1) = f(x) + x* from which it's clear that the next number in the sequence is the previous one minus its position (a bit similar to [Fibonacci](fibonacci.md) sequence), so for example this sequence will satisfy the equation: 0, 0, 1, 3, 6, 10, 15, ...
|
||||
55. yes
|
||||
|
||||
## Other
|
||||
|
||||
|
|
5
jesus.md
5
jesus.md
|
@ -45,6 +45,7 @@ As perhaps the most influential man in history whose image has been twisted, use
|
|||
- **His father** is sometimes theorized, by historians, to have been a roman soldier Tiberius Julius Abdes Pantera to whom point some of the clues and whose grave has been found in Germany.
|
||||
- Bible gives his **genealogy back to Adam**: Luke (however with some disagreement with Matthew) recounts all ancestors of Jesus back to God (who created Adam) -- Jesus is 77th in row here.
|
||||
- His **profession** probably wasn't a "carpenter" in the sense of "working mainly with wood", he was more likely a mason/stonecutter/builder -- the translation in Bible is firstly inaccurate and using wood as a material wasn't that common back then. He was likely a very poor laborer whose life conditions may have been even worse than that of some slaves living in bigger cities.
|
||||
- **He was a [Jew](jew.md)**, he was circumcised, read Jewish scriptures, believed in Jewish God, kept to Jewish rituals and traditions -- it's obvious but often overlooked fact that's been further obscured by the church and Christian culture. There was no other religion than various branches of Judaism back then, he didn't come with the idea of starting a brand new religion, he rather saw himself as a Jewish messiah foretold by the Jewish texts, walking what he believed to be the true way of the religion that was all around back then.
|
||||
- **Jesus is supposed to return** and judge the people: this is known as the Second Coming and is hinted on in the Bible, though the details on the date or even the nature of the event are unclear and interpreted differently. Before the second coming **a number of antichrists, or false prophets, are to appear**.
|
||||
- There are highly **controversial theories that he had kids** with Mary Magdalene and that his bloodline survives until today (Dan Brown has famously written some books about it).
|
||||
- ...
|
||||
|
@ -63,9 +64,9 @@ The gospel of Matthew gives a legend that says that Jesus's birth was followed b
|
|||
|
||||
There is almost nothing known about the majority of his life -- before he started his ministry -- this is called his **unknown years**. Some wild theories state that he traveled to Egypt, Asia or even the British islands, however those are mostly not accepted. More realistically it is thought that during this time Joseph (his father) died (he may have been a lot older than Mary), as he stops being mentioned completely later on, and that Jesus had to take care of his family, he probably had to work very hard; he may have worked on rebuilding the city of Sepphoris.
|
||||
|
||||
An important event was the **baptism** (the ritual of "purification by water") of Jesus in Jordan river by John the Baptist around 28 AD. This is seen as a real historical event nowadays. John the Baptist was a preacher similar to Jesus -- some historians even say they were genetically related and knew each other since young years. John started a kind of movement and baptized people in the Jordan river, and he foretold the coming of Jesus -- many of John's followers then went on to follow Jesus. Some historians say John's role has been greatly downplayed by the church so as to make Jesus the one true prophet, but more realistically it seems that John and Jesus were equals or perhaps that John was at times seen as even greater than Jesus; the Jewish prophecies for example talk about two prophets, not one, and before John's imprisonment John and Jesus were both baptizing people together (something not often shown). Later gospels leave out more and more things that hint on this fact, there is likely a lot of divergence between the church version and historical truth.
|
||||
An important event was the **baptism** (the ritual of "purification by water") of Jesus in Jordan river by John the Baptist around 28 AD. This is seen as a real historical event nowadays. John the Baptist was a preacher similar to Jesus -- some historians even say they were genetically related and knew each other since young years. John started a kind of movement and baptized people in the Jordan river, and he foretold the coming of Jesus -- many of John's followers then went on to follow Jesus. Some historians say John's role has been greatly downplayed by the church so as to make Jesus the one true prophet, but more realistically it seems that John and Jesus were equals or perhaps that John was at times seen as even greater than Jesus; the Jewish prophecies for example talk about two prophets, not one, and before John's imprisonment (and execution) John and Jesus were both baptizing people together (something not often shown). Later gospels leave out more and more things that hint on this fact, there is likely a lot of divergence between the church version and historical truth.
|
||||
|
||||
After this Jesus went on to preaching, he chose **twelve apostles**, the closest followers to further preach his words to others; they were (there seems to be some differences between the gospels) Peter, Andrew, James, John, Philip, Bartholomew, Thomas, Matthew, James, Judas, Simon and Matthias. Jesus spoke in parables and made miracles like healing the blind, walking on water, feeding masses of people with only five loaves of bread and even resurrecting dead (Lazarus). His preaching was mainly about the [love](love.md) of [God](god.md), coming to God's kingdom after death, forgiveness (people should forgive others and their own sins will in turn be forgiven by God) and loving other people, even one's enemies, he advocated [nonviolence](nonviolence.md), modesty and frugality.
|
||||
After this Jesus went on to preaching, he chose **twelve apostles**, the closest followers to further preach his words to others; they were (there seems to be some differences between the gospels) Peter, Andrew, James, John, Philip, Bartholomew, Thomas, Matthew, James, Judas, Simon and Matthias. Some of them were likely his own brothers. Jesus spoke in parables and is said to have performed miracles like healing the blind, walking on water, feeding masses of people with only five loaves of bread and even resurrecting dead (Lazarus). His preaching was mainly about the [love](love.md) of [God](god.md), coming to God's kingdom after death, forgiveness (people should forgive others and their own sins will in turn be forgiven by God) and loving other people, even one's enemies, he advocated [nonviolence](nonviolence.md), modesty and frugality.
|
||||
|
||||
As he arrived to Jerusalem, he was very famous and seen as a messiah by many, and as he broke many religious traditions, he began to upset the Jewish religious leaders, creating tension. He criticized practices of the leaders, e.g. commerce in temples. The Jews decided to arrest Jesus and lead him to Roman court.
|
||||
|
||||
|
|
2
linux.md
2
linux.md
|
@ -2,7 +2,7 @@
|
|||
|
||||
{ At this point it's best to start using a different kernel if you can. Consider BSD or Hurd maybe. ~drummyfish }
|
||||
|
||||
Linux (also Lunix or Loonix) is a partially "[open-source](open_source.md)" [unix-like](unix_like.md) [operating system](operating_system.md) [kernel](kernel.md), probably the most successful "mostly FOSS" kernel, nowadays already killed by [capitalism](capitalism.md). One of its greatest advantages was support of a lot of [hardware](hardware.md); it runs besides others on [x86](x86.md], [PowerPC](ppc.md), [Arm](arm.md), has many [drivers](driver.md) and can be compiled to be quite small so as to run well even on very weak computers. **Linux is NOT an operating system**, only its basic part -- for a whole operating system more things need to be added, such as some kind of [user interface](ui.md) and actual user programs (so called [userland](userland.md)), and this is what [Linux distributions](linux_distro.md) do (there hundreds of these) -- Linux distributions, such as [Debian](debian.md), [Arch](arch.md) or [Ubuntu](ubuntu.md) are complete operating systems (but beware, most of them are not fully [FOSS](foss.md)). The mascot of the project is a penguin named [Tux](tux.md) (under some vague non-standard [license](license.md)). Linux is one of the biggest collaborative programming projects, as of now it has more than 15000 contributors. Despite popular misconceptions **Linux is [proprietary](proprietary.md) software** by containing [binary blobs](binary_blob.md) -- completely free distributions have to use forks that remove these (see e.g. [Linux-libre](linux_libre.md), [Debian](debian.md)'s Linux fork etc.). Linux is also **greatly [bloated](bloat.md)** (though not anywhere near [Windows](windows.md) and such) and **[tranny software](tranny_software.md)**, abusing technology as a vehicle for promoting [harmful politics](sjw.md). While back in the day Linux was one of the coolest projects, by 2024 **Linux is absolute shit**, it has [code of censorship](coc.md), it's hijacked by capitalism, developed by corporations and fascists ([feminists](feminism.md), [LGBT](lgbt.md), ...), overcomplicated, commercialized, full of [Rust](rust.md) code; there are already even backdoor popping in (see the 2004 XZ scandal), basically it's almost unusable now. The spirit, significance, journey and eventual fate of Linux are similar to e.g. [Wikipedia](wikipedia.md).
|
||||
Linux (also Lunix or Loonix) is a partially "[open-source](open_source.md)" [unix-like](unix_like.md) [operating system](operating_system.md) [kernel](kernel.md), probably the most successful "mostly FOSS" kernel, nowadays already killed by [capitalism](capitalism.md). One of its greatest advantages was support of a lot of [hardware](hardware.md); it runs besides others on [x86](x86.md], [PowerPC](ppc.md), [Arm](arm.md), has many [drivers](driver.md) and can be compiled to be quite small so as to run well even on very weak computers. **Linux is NOT an operating system**, only its basic part -- for a whole operating system more things need to be added, such as some kind of [user interface](ui.md) and actual user programs (so called [userland](userland.md)), and this is what [Linux distributions](linux_distro.md) do (there hundreds of these) -- Linux distributions, such as [Debian](debian.md), [Arch](arch.md) or [Ubuntu](ubuntu.md) are complete operating systems (but beware, most of them are not fully [FOSS](foss.md)). The mascot of the project is a penguin named [Tux](tux.md) (under some vague non-standard [license](license.md)). Linux is one of the biggest collaborative programming projects, as of now it has more than 15000 contributors. Despite popular misconceptions **Linux is [proprietary](proprietary.md) software** by containing [binary blobs](binary_blob.md) -- completely free distributions have to use forks that remove these (see e.g. [Linux-libre](linux_libre.md), [Debian](debian.md)'s Linux fork etc.). Linux is also **greatly [bloated](bloat.md)** (though not anywhere near [Windows](windows.md) and such) and **[tranny software](tranny_software.md)**, abusing technology as a vehicle for promoting [harmful politics](sjw.md). While back in the day Linux was one of the coolest projects, by 2024 **Linux is absolute shit**, it has [code of censorship](coc.md), it's hijacked by capitalism, developed by corporations and fascists ([feminists](feminism.md), [LGBT](lgbt.md), ...), overcomplicated, commercialized, full of [Rust](rust.md) code; there are already even backdoor popping in (see the 2024 XZ scandal), basically it's almost unusable now. The spirit, significance, journey and eventual fate of Linux are similar to e.g. [Wikipedia](wikipedia.md).
|
||||
|
||||
[Fun](fun.md) note: there is a site that counts certain words in the Linux source code, https://www.vidarholen.net/contents/wordcount. For the lulz in 2019 some word counts were: "fuck": 16, "shit": 33, "idiot": 17, "retard": 4, "hack": 1571, "todo": 6166, "fixme": 4256.
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ Open source (OS, also *Open $ource*) is a [capitalist](capitalism.md) movement,
|
|||
|
||||
Open source unfortunately (but unsurprisingly) became absolutely prevalent over free software as it better serves [capitalism](capitalism.md) and abuse of people, and its followers are more and more hostile towards the free software movement. This is very dangerous, [ethics](ethics.md) and focus on actual user freedom is replaced by shallow legal definitions that can be bypassed, e.g. by [capitalist software](capitalist_software.md) and [bloat monopoly](bloat_monopoly.md). In a way open source is capitalism reshaping free software so as to weaken it and eventually make its principles of freedom ineffective. Open source tries to shift the goal posts: more and more it offers only an illusion of some kind of ethics and/or freedom, it pushes towards mere partial openness ("open source" for proprietary platforms), towards high complexity, inclusion of unethical business-centered features ([autoupdates](autoupdate.md), [DRM](drm.md), ...), high interdependency, difficulty of utilizing the rights granted by the license, exclusion of developers with "incorrect" political opinions or bad brand image etc. In practice open source has become something akin a mere **brand** which is stick to a piece of software to give users with little insight a feeling they're buying into something good -- this is called **[openwashing](openwashing.md)**. This claim is greatly supported by the fact that corporations such as [Microsoft](microsoft.md) and [Google](google.md) widely embrace open source ("Microsoft <3 open source", the infamous [GitHub](github.md) acquisition etc.).
|
||||
|
||||
"Open source" as a term and brand arose by the group of capitalists, such as [Linus Torvalds](linus_torvalds.md) and [Eric. S. Raymond](esr.md) (author of [The Cathedral And Bazaar](bazaar.md), a guide of how to exploit programmers to maximize profit), who were at the time part of the [free software movement](free_software.md) but at the same time felt great sadness that they couldn't make enough money on something that's focused on ethical goals. At the beginning of 1998 some of these businessmen held a meeting in Palo Alto with the goal of shifting the goal posts where one of them -- allegedly Christine Peterson (a [woman](woman.md)) -- suggested the term "open source" (other alternatives were e.g. "sourceware") which then passed by vote. Consequently the next month the *Open Source Initiative* ([OSI](osi.md)), a new propaganda organization, was formed, with Raymond as its president. Sadly most of the self proclaimed "anticapitalist rebels" among [zoomers](zoomer.md) aren't even aware of this recent history and happily follow this purely capitalist movement, use the terms *open source*, embrace and use anything with the *open source* sticker on it, use [GitHub](github.md) etc., thinking they're "opposing something". This is exactly what Open Source wanted to achieve, a false sense of rebellion that will actually make most programmers do their bidding.
|
||||
|
||||
*"**Free and Open Source**: it is completely **FREE OF COST** and **ALMOST ALL** of its components are open source."* --GNU/Linux [Mint](mint.md)'s website already marketing partially proprietary system as "open source" and purposefully misusing the word "free" to mean "gratis" (February 2024)
|
||||
|
||||
{ Mint also hilariously markets itself as [KISS](kiss.md) lol. My friend suggested they only implemented the "stupid" part of it :-) ~drummyfish }
|
||||
|
|
3394
random_page.md
3394
random_page.md
File diff suppressed because it is too large
Load diff
2
rms.md
2
rms.md
|
@ -19,6 +19,8 @@ Stallman's life along with free software's history is documented by a free-licen
|
|||
|
||||
Richard Stallman is also famous for having foreseen and foretold virtually all the atrocities that [corporations](corporation.md) would do with computer technology, such as all the spying through cell phones, trade of personal data and abusing secrecy and "[intellectual ownership](intellectual_property.md)" of source code for bullying others, though to be honest it doesn't take a genius to foresee that corporations will want to rape people as much as possible, it's more of a surprise he was one of very few who did. The important thing is he acted immediately he spotted this -- though corporations indeed did go on to rape people anyway, Richard Stallman made some very important steps early on to make the impact much less catastrophic nowadays. We should be all grateful.
|
||||
|
||||
It seems that **Stallman had at least one girlfriend**; in the 1999 book called *Open Sources* he says that he originally wanted to name the [HURD](hurd.md) kernel Alix after a [girl](woman.md) that was at the time his "sweetheart".
|
||||
|
||||
[tl;dr](tldr.md): At 27 as an employee at [MIT](mit.md) [AI](ai.md) labs Stallman had a bad experience when trying to fix a Xerox printer who's [proprietary](proprietary.md) software source code was made inaccessible; he also started spotting the betrayal of hacker principles by others who decided to write proprietary software -- he realized proprietary software was inherently wrong as it prevented studying, improvement and sharing of software and enable abuse of users. From 1982 he was involved in a "fight" against the Symbolics company that pushed aggressive proprietary software; he was rewriting their software from scratch to allow Lisp Machine users more freedom -- here he proved his superior programming skills as he was keeping up with the whole team of Symbolics programmers. By 1983 his frustration reached its peak and he announced his [GNU](gnu.md) project on the [Usenet](usenet.md) -- this was a project to create a completely [free as in freedom](free_software.md) [operating system](os.md), an alternative to the proprietary [Unix](unix.md) system that would offer its users freedom to use, study, modify and share the whole software, in the hacker spirit. He followed by publishing a manifesto and establishing the [Free Software Foundation](fsf.md). GNU and FSF popularized and standardized the term [free (as in freedom) software](free_software.md), [copyleft](copyleft.md) and free licensing, mainly with the [GPL](gpl.md) license. In the 90s GNU adopted the [Linux](linux.md) operating system kernel and released a complete version of the GNU operating system -- these are nowadays known mostly as "Linux" [distros](distro.md). As a head of FSF and GNU Stallman more or less stopped programming and started traveling around the world to give talks about free software and has earned his status of one of the most important people in software history.
|
||||
|
||||
Regarding [software](software.md) Stallman has for his whole life strongly and tirelessly promoted free software and [copyleft](copyleft.md) and has himself only used free software; he has always practiced what he preached and led the best example of how to live without [proprietary](proprietary.md) software. This in itself is extremely amazing and rare, regardless of whether he ever slipped (which we aren't aware of) or to what degree we agree with his ideas; his moral strength and integrity is really what makes him special among basically all other great people of recent centuries, it's really as if he comes from a different time when people TRULY internally believed something so much they would die for it, that they wouldn't sell even a small part of that belief for any kind of personal benefit; this is something that really puts him alongside the greatest philosophers such as [Plato](plato.md) or [Socrates](socrates.md) (who followed his own principles so much that he voluntarily died for them).
|
||||
|
|
108
rsa.md
108
rsa.md
|
@ -9,7 +9,7 @@ generating keys:
|
|||
3. *n := p * q*
|
||||
4. *f := (p - 1) * (q - 1)* (this step may differ in other versions)
|
||||
5. *e := 65537* (most common, other constants exist)
|
||||
6. *d := solve for x: x * e = 1 mod f*
|
||||
6. *d := solve for x: 1 = (x * e) mod f*
|
||||
7. *public key := (n,e)*
|
||||
8. *private key := d*
|
||||
|
||||
|
@ -22,3 +22,109 @@ message decryption:
|
|||
|
||||
1. *m := encrypted^d mod n*
|
||||
2. *decrypted := decode message from number m*
|
||||
|
||||
## Code Example
|
||||
|
||||
Here is a stupidly simple [C](c.md) code demonstrating the algorithm, for simplicity we use laughably small primes, we only consider 4 character string as a message and make other simplifications.
|
||||
|
||||
```
|
||||
#include <stdio.h>
|
||||
#define e 65537 // often used constant
|
||||
|
||||
typedef unsigned long long u64;
|
||||
|
||||
void generateKeys(u64 prime1, u64 prime2, u64 *privateKey, u64 *publicKey)
|
||||
{
|
||||
u64 f = (prime1 - 1) * (prime2 - 1);
|
||||
|
||||
*publicKey = prime1 * prime2;
|
||||
*privateKey = 1;
|
||||
|
||||
while (*privateKey) // brute force solve the equation
|
||||
{
|
||||
if (((*privateKey) * e) % f == 1)
|
||||
break;
|
||||
|
||||
(*privateKey)++;
|
||||
}
|
||||
}
|
||||
|
||||
u64 powerMod(u64 n, u64 power, u64 mod) // helper func, returns n^power % mod
|
||||
{
|
||||
u64 result = 1;
|
||||
|
||||
for (int i = 0; i < power; ++i)
|
||||
result = (result * n) % mod;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
u64 encryptNum(u64 n, u64 publicKey)
|
||||
{
|
||||
return powerMod(n,e,publicKey);
|
||||
}
|
||||
|
||||
u64 decryptNum(u64 n, u64 publicKey, u64 privateKey)
|
||||
{
|
||||
return powerMod(n,privateKey,publicKey);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
u64 priv, pub,
|
||||
prime1 = 33461,
|
||||
prime2 = 17977;
|
||||
|
||||
const char *str = "bich"; // we'll only consider 4 char string
|
||||
|
||||
puts("generating keys, wait...");
|
||||
|
||||
generateKeys(prime1,prime2,&priv,&pub);
|
||||
|
||||
printf("prime1 = %llu\nprime2 = %llu\nprivate key = %llu\npublic key = %llu\n",
|
||||
prime1,prime2,priv,pub);
|
||||
|
||||
u64 data = str[0] | (str[1] << 7) | (str[2] << 14) | (str[3] << 21);
|
||||
|
||||
printf("string to encode: \"%s\"\n",str);
|
||||
printf("string as numeric data: %lld\n",data);
|
||||
|
||||
if (data >= pub)
|
||||
{
|
||||
puts("Data is too big, choose bigger primes or smaller data.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
puts("encrypting...");
|
||||
|
||||
u64 encrypted = encryptNum(data,pub);
|
||||
printf("encrypted: %lld\n",encrypted);
|
||||
|
||||
puts("decrypting...");
|
||||
|
||||
data = decryptNum(encrypted,pub,priv);
|
||||
printf("decrypted: %lld\n",data);
|
||||
|
||||
printf("retrieved string: \"%c%c%c%c\"\n",data & 0x7f,(data >> 7) & 0x7f,
|
||||
(data >> 14) & 0x7f,(data >> 21) & 0x7f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
The program prints out:
|
||||
|
||||
```
|
||||
generating keys, wait...
|
||||
prime1 = 33461
|
||||
prime2 = 17977
|
||||
private key = 323099873
|
||||
public key = 601528397
|
||||
string to encode: "bich"
|
||||
string as numeric data: 219739362
|
||||
encrypting...
|
||||
encrypted: 233361060
|
||||
decrypting...
|
||||
decrypted: 219739362
|
||||
retrieved string: "bich"
|
||||
```
|
File diff suppressed because one or more lines are too long
|
@ -3,8 +3,8 @@
|
|||
This is an autogenerated article holding stats about this wiki.
|
||||
|
||||
- number of articles: 578
|
||||
- number of commits: 783
|
||||
- total size of all texts in bytes: 3702811
|
||||
- number of commits: 784
|
||||
- total size of all texts in bytes: 3704463
|
||||
- total number of lines of article texts: 28471
|
||||
- number of script lines: 262
|
||||
- occurences of the word "person": 8
|
||||
|
@ -36,26 +36,26 @@ longest articles:
|
|||
top 50 5+ letter words:
|
||||
|
||||
- which (2118)
|
||||
- there (1603)
|
||||
- there (1604)
|
||||
- people (1396)
|
||||
- other (1157)
|
||||
- other (1159)
|
||||
- example (1132)
|
||||
- software (1043)
|
||||
- software (1046)
|
||||
- number (1015)
|
||||
- about (960)
|
||||
- about (961)
|
||||
- program (853)
|
||||
- their (799)
|
||||
- because (752)
|
||||
- called (736)
|
||||
- because (753)
|
||||
- called (737)
|
||||
- would (723)
|
||||
- computer (721)
|
||||
- language (716)
|
||||
- being (698)
|
||||
- being (699)
|
||||
- simple (691)
|
||||
- things (683)
|
||||
- numbers (678)
|
||||
- without (642)
|
||||
- something (640)
|
||||
- numbers (679)
|
||||
- without (644)
|
||||
- something (641)
|
||||
- function (637)
|
||||
- programming (636)
|
||||
- these (600)
|
||||
|
@ -65,16 +65,16 @@ top 50 5+ letter words:
|
|||
- system (551)
|
||||
- should (540)
|
||||
- games (537)
|
||||
- doesn (526)
|
||||
- doesn (527)
|
||||
- point (525)
|
||||
- society (521)
|
||||
- society (522)
|
||||
- though (498)
|
||||
- memory (495)
|
||||
- while (490)
|
||||
- drummyfish (489)
|
||||
- using (487)
|
||||
- technology (474)
|
||||
- still (468)
|
||||
- still (469)
|
||||
- course (465)
|
||||
- similar (463)
|
||||
- simply (448)
|
||||
|
@ -89,6 +89,22 @@ top 50 5+ letter words:
|
|||
latest changes:
|
||||
|
||||
```
|
||||
Date: Sun Apr 28 20:29:29 2024 +0200
|
||||
21st_century.md
|
||||
4chan.md
|
||||
attribution.md
|
||||
bullshit.md
|
||||
drummyfish.md
|
||||
exercises.md
|
||||
iq.md
|
||||
love.md
|
||||
physics_engine.md
|
||||
programming.md
|
||||
random_page.md
|
||||
reddit.md
|
||||
wiki_pages.md
|
||||
wiki_stats.md
|
||||
www.md
|
||||
Date: Sat Apr 27 20:35:26 2024 +0200
|
||||
english.md
|
||||
exercises.md
|
||||
|
@ -108,19 +124,6 @@ Date: Sat Apr 27 20:35:26 2024 +0200
|
|||
wikipedia.md
|
||||
woman.md
|
||||
Date: Fri Apr 26 20:00:04 2024 +0200
|
||||
exercises.md
|
||||
lgbt.md
|
||||
random_page.md
|
||||
wiki_pages.md
|
||||
wiki_stats.md
|
||||
Date: Thu Apr 25 20:58:19 2024 +0200
|
||||
exercises.md
|
||||
fail_ab.md
|
||||
human_language.md
|
||||
lmao.md
|
||||
random_page.md
|
||||
wiki_pages.md
|
||||
wiki_stats.md
|
||||
```
|
||||
|
||||
most wanted pages:
|
||||
|
@ -153,7 +156,7 @@ most popular and lonely pages:
|
|||
- [c](c.md) (205)
|
||||
- [bloat](bloat.md) (198)
|
||||
- [free_software](free_software.md) (163)
|
||||
- [game](game.md) (137)
|
||||
- [game](game.md) (138)
|
||||
- [suckless](suckless.md) (132)
|
||||
- [proprietary](proprietary.md) (114)
|
||||
- [kiss](kiss.md) (92)
|
||||
|
@ -169,12 +172,12 @@ most popular and lonely pages:
|
|||
- [censorship](censorship.md) (75)
|
||||
- [public_domain](public_domain.md) (74)
|
||||
- [foss](foss.md) (74)
|
||||
- [less_retarded_society](less_retarded_society.md) (71)
|
||||
- [hacking](hacking.md) (71)
|
||||
- [fight_culture](fight_culture.md) (71)
|
||||
- [bullshit](bullshit.md) (71)
|
||||
- [art](art.md) (71)
|
||||
- [programming_language](programming_language.md) (70)
|
||||
- [less_retarded_society](less_retarded_society.md) (70)
|
||||
- [shit](shit.md) (68)
|
||||
- [float](float.md) (66)
|
||||
- [chess](chess.md) (64)
|
||||
|
|
Loading…
Reference in a new issue