-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-init-crypto
executable file
·79 lines (72 loc) · 2.28 KB
/
git-init-crypto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
if [[ $# -eq 2 ]]; then
PASS=$2
else
echo -n Enter password:
read -s PASS
printf '\n'
echo -n Retype password:
read -s RETYPED_PASS
printf '\n'
if [ "$PASS" != "$RETYPED_PASS" ]; then
echo "Passwords does not match!"
exit -1
fi
fi
FOLDER=$1
GIT_CONFIG=".git/config"
GIT_ATTRIBUTES=".gitattributes"
CRYPTO_DIR=".git/.crypto"
CLEAN_FILTER="$CRYPTO_DIR/cleanFilter"
SMUDGE_FILTER="$CRYPTO_DIR/smudgeFilter"
DIFF_FILTER="$CRYPTO_DIR/diffFilter"
if [ ! -d "$FOLDER" ]; then
echo "Directory does not exist: creating"
mkdir $FOLDER
fi
git init $FOLDER
cd $FOLDER
if [ -n "$NO_CREATE_GITATTRIBUTES" ]; then
echo "Skipping creation of .gitattributes file"
else
echo "*.cpp filter=aes diff=aes" >> $GIT_ATTRIBUTES
echo "*.hpp filter=aes diff=aes" >> $GIT_ATTRIBUTES
git add .gitattributes
git commit -m"Initial CryptoGit commit"
fi
########################################################
echo '[filter "aes"]' >> $GIT_CONFIG
echo " smudge = $SMUDGE_FILTER" >> $GIT_CONFIG
echo " clean = $CLEAN_FILTER" >> $GIT_CONFIG
echo '[diff "aes"]' >> $GIT_CONFIG
echo " textconv = $DIFF_FILTER" >> $GIT_CONFIG
echo "" >> $GIT_CONFIG
########################################################
mkdir $CRYPTO_DIR
########################################################
echo "#!/bin/bash" >> $CLEAN_FILTER
echo "" >> $CLEAN_FILTER
echo "SALT=7F23" >> $CLEAN_FILTER
echo "" >> $CLEAN_FILTER
echo "PASS=$PASS" >> $CLEAN_FILTER
echo "" >> $CLEAN_FILTER
echo 'openssl enc -e -base64 -aes-128-cfb -S $SALT -k $PASS' >> $CLEAN_FILTER
echo "" >> $CLEAN_FILTER
chmod +x $CLEAN_FILTER
########################################################
echo "#!/bin/bash" >> $SMUDGE_FILTER
echo "" >> $SMUDGE_FILTER
echo "PASS=$PASS" >> $SMUDGE_FILTER
echo "" >> $SMUDGE_FILTER
echo 'openssl enc -d -base64 -aes-128-cfb -k $PASS' >> $SMUDGE_FILTER
echo "" >> $SMUDGE_FILTER
chmod +x $SMUDGE_FILTER
########################################################'
echo "#!/bin/bash" >> $DIFF_FILTER
echo "" >> $DIFF_FILTER
echo "PASS=$PASS" >> $DIFF_FILTER
echo "" >> $DIFF_FILTER
echo 'openssl enc -d -base64 -aes-128-cfb -k $PASS -in "$1" || cat "$1"' >> $DIFF_FILTER
echo "" >> $DIFF_FILTER
chmod +x $DIFF_FILTER
########################################################