mirror of
https://codeberg.org/scip/bubblebabble.git
synced 2025-12-16 02:40:57 +01:00
move to codeberg (#1)
This commit is contained in:
25
.woodpecker/build.yaml
Normal file
25
.woodpecker/build.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
matrix:
|
||||
platform:
|
||||
- linux/amd64
|
||||
|
||||
labels:
|
||||
platform: ${platform}
|
||||
|
||||
steps:
|
||||
build:
|
||||
when:
|
||||
event: [push]
|
||||
image: alpine:latest
|
||||
commands:
|
||||
- apk update
|
||||
- apk add --no-cache bash build-base
|
||||
- make
|
||||
|
||||
test:
|
||||
when:
|
||||
event: [push]
|
||||
image: alpine:latest
|
||||
commands:
|
||||
- apk update
|
||||
- apk add --no-cache bash
|
||||
- echo hier | ./bubblebabble | grep xipak-nynil-dedox
|
||||
49
Makefile
Normal file
49
Makefile
Normal file
@@ -0,0 +1,49 @@
|
||||
#
|
||||
# This file is part of bubblebabble.
|
||||
#
|
||||
# Copyright (C) 2018-2025 T.v.Dein.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# You can contact me by mail: <tom AT vondein DOT org>.
|
||||
|
||||
.PHONY: all clean man install
|
||||
|
||||
# warning: do not set -O to 2, see TODO
|
||||
CFLAGS = -Wall -Wextra -Werror -O1 -g
|
||||
LDFLAGS=
|
||||
OBJS = main.o bubblebabble.o
|
||||
DST = bubblebabble
|
||||
PREFIX = /usr/local
|
||||
UID = root
|
||||
GID = 0
|
||||
|
||||
all: $(DST)
|
||||
|
||||
$(DST): $(OBJS)
|
||||
$(CC) $(OBJS) -o $(DST)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) $*.c -o $*.o
|
||||
|
||||
clean:
|
||||
rm -rf *.o $(DST) build .cache
|
||||
|
||||
man:
|
||||
pod2man udpxd.pod > udpxd.1
|
||||
|
||||
install: $(DST)
|
||||
install -d -o $(UID) -g $(GID) $(PREFIX)/bin
|
||||
install -o $(UID) -g $(GID) -m 555 $(DST) $(PREFIX)/bin/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# bubblebabble
|
||||
|
||||
Encode to Bubble Babble
|
||||
|
||||
## Intro
|
||||
@@ -10,8 +11,8 @@ function so you can encode anything to bubble babble.
|
||||
|
||||
## Compile and Install
|
||||
|
||||
gcc -g bubblebabble.c -o bubblebabble
|
||||
sudo install -o root -g wheel bubblebabble /usr/local/bin/
|
||||
make
|
||||
sudo make install
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -20,7 +21,7 @@ function so you can encode anything to bubble babble.
|
||||
|
||||
## Copyright + Author
|
||||
|
||||
- Copyright (c) 2017 T.v.Dein. All rights reserved.
|
||||
- Copyright (c) 2017-2025 T.v.Dein. All rights reserved.
|
||||
|
||||
fingerprint_bubblebabble():
|
||||
|
||||
|
||||
121
bubblebabble.c
121
bubblebabble.c
@@ -30,89 +30,48 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "bubblebabble.h"
|
||||
|
||||
static char *
|
||||
fingerprint_bubblebabble(u_char *dgst_raw, size_t dgst_raw_len)
|
||||
{
|
||||
char vowels[] = { 'a', 'e', 'i', 'o', 'u', 'y' };
|
||||
char consonants[] = { 'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm',
|
||||
'n', 'p', 'r', 's', 't', 'v', 'z', 'x' };
|
||||
u_int i, j = 0, rounds, seed = 1;
|
||||
char *retval;
|
||||
char *fingerprint_bubblebabble(u_char *dgst_raw, size_t dgst_raw_len) {
|
||||
char vowels[] = {'a', 'e', 'i', 'o', 'u', 'y'};
|
||||
char consonants[] = {'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm',
|
||||
'n', 'p', 'r', 's', 't', 'v', 'z', 'x'};
|
||||
u_int i, j = 0, rounds, seed = 1;
|
||||
char *retval;
|
||||
|
||||
rounds = (dgst_raw_len / 2) + 1;
|
||||
if ((retval = calloc(rounds, 6)) == NULL)
|
||||
return NULL;
|
||||
retval[j++] = 'x';
|
||||
for (i = 0; i < rounds; i++) {
|
||||
u_int idx0, idx1, idx2, idx3, idx4;
|
||||
if ((i + 1 < rounds) || (dgst_raw_len % 2 != 0)) {
|
||||
idx0 = (((((u_int)(dgst_raw[2 * i])) >> 6) & 3) +
|
||||
seed) % 6;
|
||||
idx1 = (((u_int)(dgst_raw[2 * i])) >> 2) & 15;
|
||||
idx2 = ((((u_int)(dgst_raw[2 * i])) & 3) +
|
||||
(seed / 6)) % 6;
|
||||
retval[j++] = vowels[idx0];
|
||||
retval[j++] = consonants[idx1];
|
||||
retval[j++] = vowels[idx2];
|
||||
if ((i + 1) < rounds) {
|
||||
idx3 = (((u_int)(dgst_raw[(2 * i) + 1])) >> 4) & 15;
|
||||
idx4 = (((u_int)(dgst_raw[(2 * i) + 1]))) & 15;
|
||||
retval[j++] = consonants[idx3];
|
||||
retval[j++] = '-';
|
||||
retval[j++] = consonants[idx4];
|
||||
seed = ((seed * 5) +
|
||||
((((u_int)(dgst_raw[2 * i])) * 7) +
|
||||
((u_int)(dgst_raw[(2 * i) + 1])))) % 36;
|
||||
}
|
||||
} else {
|
||||
idx0 = seed % 6;
|
||||
idx1 = 16;
|
||||
idx2 = seed / 6;
|
||||
retval[j++] = vowels[idx0];
|
||||
retval[j++] = consonants[idx1];
|
||||
retval[j++] = vowels[idx2];
|
||||
}
|
||||
}
|
||||
retval[j++] = 'x';
|
||||
retval[j++] = '\0';
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
FILE *input;
|
||||
u_char digest[1024];
|
||||
size_t digestlen;
|
||||
char *hash;
|
||||
int out = 1;
|
||||
|
||||
if(argc < 2) {
|
||||
input = stdin;
|
||||
}
|
||||
else {
|
||||
if((input = fopen(argv[1], "rb")) == NULL) {
|
||||
fprintf(stderr, "oops, could not open file!\n");
|
||||
goto done;
|
||||
rounds = (dgst_raw_len / 2) + 1;
|
||||
if ((retval = calloc(rounds, 6)) == NULL)
|
||||
return NULL;
|
||||
retval[j++] = 'x';
|
||||
for (i = 0; i < rounds; i++) {
|
||||
u_int idx0, idx1, idx2, idx3, idx4;
|
||||
if ((i + 1 < rounds) || (dgst_raw_len % 2 != 0)) {
|
||||
idx0 = (((((u_int)(dgst_raw[2 * i])) >> 6) & 3) + seed) % 6;
|
||||
idx1 = (((u_int)(dgst_raw[2 * i])) >> 2) & 15;
|
||||
idx2 = ((((u_int)(dgst_raw[2 * i])) & 3) + (seed / 6)) % 6;
|
||||
retval[j++] = vowels[idx0];
|
||||
retval[j++] = consonants[idx1];
|
||||
retval[j++] = vowels[idx2];
|
||||
if ((i + 1) < rounds) {
|
||||
idx3 = (((u_int)(dgst_raw[(2 * i) + 1])) >> 4) & 15;
|
||||
idx4 = (((u_int)(dgst_raw[(2 * i) + 1]))) & 15;
|
||||
retval[j++] = consonants[idx3];
|
||||
retval[j++] = '-';
|
||||
retval[j++] = consonants[idx4];
|
||||
seed = ((seed * 5) + ((((u_int)(dgst_raw[2 * i])) * 7) +
|
||||
((u_int)(dgst_raw[(2 * i) + 1])))) %
|
||||
36;
|
||||
}
|
||||
} else {
|
||||
idx0 = seed % 6;
|
||||
idx1 = 16;
|
||||
idx2 = seed / 6;
|
||||
retval[j++] = vowels[idx0];
|
||||
retval[j++] = consonants[idx1];
|
||||
retval[j++] = vowels[idx2];
|
||||
}
|
||||
}
|
||||
|
||||
digestlen = fread(digest, 1, 1024, input);
|
||||
|
||||
if(digestlen > 0) {
|
||||
hash = fingerprint_bubblebabble(digest, digestlen);
|
||||
fprintf(stdout, "%s\n", hash);
|
||||
free(hash);
|
||||
out = 0;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "oops, could not calculate bubbles!\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
return out;
|
||||
retval[j++] = 'x';
|
||||
retval[j++] = '\0';
|
||||
return retval;
|
||||
}
|
||||
|
||||
31
bubblebabble.h
Normal file
31
bubblebabble.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
This file is part of bubblebabble.
|
||||
|
||||
Copyright (C) 2018-2025 T.v.Dein.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact me by mail: <tom AT vondein DOT org>.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_BUBABL
|
||||
#define HAVE_BUBABL 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
char *fingerprint_bubblebabble(u_char *dgst_raw, size_t dgst_raw_len);
|
||||
|
||||
#endif
|
||||
54
main.c
Normal file
54
main.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
This file is part of bubblebabble.
|
||||
|
||||
Copyright (C) 2018-2025 T.v.Dein.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact me by mail: <tom AT vondein DOT org>.
|
||||
*/
|
||||
|
||||
#include "bubblebabble.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
FILE *input;
|
||||
u_char digest[1024];
|
||||
size_t digestlen;
|
||||
char *hash;
|
||||
int out = 1;
|
||||
|
||||
if (argc < 2) {
|
||||
input = stdin;
|
||||
} else {
|
||||
if ((input = fopen(argv[1], "rb")) == NULL) {
|
||||
fprintf(stderr, "oops, could not open file!\n");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
digestlen = fread(digest, 1, 1024, input);
|
||||
|
||||
if (digestlen > 0) {
|
||||
hash = fingerprint_bubblebabble(digest, digestlen);
|
||||
fprintf(stdout, "%s\n", hash);
|
||||
free(hash);
|
||||
out = 0;
|
||||
} else {
|
||||
fprintf(stderr, "oops, could not calculate bubbles!\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
return out;
|
||||
}
|
||||
Reference in New Issue
Block a user