summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-04-10 17:59:20 +0000
committerCoprDistGit <infra@openeuler.org>2023-04-10 17:59:20 +0000
commitc7da610fea25655e61bafe78a7e3beac82504d01 (patch)
tree334189e7efb6b259c5dd536f157c210999720d60
parent85b5b16fa495df1a43e9f433dc680cb780018409 (diff)
automatic import of python-cryptocode
-rw-r--r--.gitignore1
-rw-r--r--python-cryptocode.spec304
-rw-r--r--sources1
3 files changed, 306 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..e91eb8a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/cryptocode-0.1.tar.gz
diff --git a/python-cryptocode.spec b/python-cryptocode.spec
new file mode 100644
index 0000000..f7695c5
--- /dev/null
+++ b/python-cryptocode.spec
@@ -0,0 +1,304 @@
+%global _empty_manifest_terminate_build 0
+Name: python-cryptocode
+Version: 0.1
+Release: 1
+Summary: Python library used to encrypt and decrypt strings in the simplest possible way.
+License: MIT
+URL: https://github.com/gdavid7/cryptocode
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/ea/b8/f4a618a4e5e7eacaaefa5ae3531cc2c12a2c880c9a7ef7f81eed6162616f/cryptocode-0.1.tar.gz
+BuildArch: noarch
+
+Requires: python3-pycryptodomex
+
+%description
+# cryptocode
+
+Python library used to encrypt and decrypt strings in the simplest possible way, while also being incredibly secure.
+## Requirements
+
+
+- **Python** 3 or later.
+
+## Installation
+
+Install some Python utilities along with some libraries and other stuff:
+
+~~~
+pip install cryptocode
+~~~
+
+## Basic usage
+Encrypting a message:
+
+~~~
+>>> import cryptocode
+>>> myEncryptedMessage = cryptocode.encrypt("I like trains", "password123")
+>>> print(myEncryptedMessage)
+M+Wykmlub0z7FhEdmA==*PvAbXRNx0SiSDHHxLsKZ5w==*ihQM/fdkgrX3G+yOItyAUQ==*QFNDmuUP1ysgo01/P2MNpg==
+~~~
+
+The first parameter is the string you want to encrypt. The second parameter is the password, which will be used for decrypting the string.
+
+Decrypting a message"
+~~~
+>>> import cryptocode
+>>> myDecryptedMessage = cryptocode.decrypt("M+Wykmlub0z7FhEdmA==*PvAbXRNx0SiSDHHxLsKZ5w==*ihQM/fdkgrX3G+yOItyAUQ==*QFNDmuUP1ysgo01/P2MNpg==", "password123")
+>>> print(myDecryptedMessage)
+I like trains
+~~~
+The first parameter is the encrypted string and the second parameter is the password. If the password is incorrect, decrypt function will return `False`.
+
+## Example
+Here, we will be creating a simple "trial product key". This is useful if you have software that you would like people to use temporarily.
+In this example, we will be letting the user use the product for 2 hours. The password we will be using is ``cryptocode is amazing``.
+
+Code on the server side:
+~~~
+import cryptocode
+import time
+hours = 2
+messageToEncrypt = str(time.time() + hours * 60 * 60)
+## Hours * 60 * 60 is necessary because we need to turn the hours into seconds, since the timestamp is in seconds.
+cryptocode.encrypt(messageToEncrypt, "cryptocode is amazing")
+~~~
+
+Code on the client side:
+~~~
+import cryptocode
+import time
+import sys
+#Function to verify that the key is valid:
+def check_valid(key):
+ message = cryptocode.decrypt(key, 'cryptocode is amazing')
+ if message == False:
+ #The key is incorrect!
+ return False
+ if float(message) >= time.time():
+ return True
+ else:
+ #The key has expired!
+ return False
+userKeyInput = input("Please enter your product key.")
+keyChecked = check_valid(userKeyInput)
+if keyChecked == True:
+ print("You are good to go!")
+if keyChecked == False:
+ print("You have either entered an invalid key or your time has expired. Sorry!")
+ sys.exit()
+~~~
+
+
+
+
+%package -n python3-cryptocode
+Summary: Python library used to encrypt and decrypt strings in the simplest possible way.
+Provides: python-cryptocode
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-cryptocode
+# cryptocode
+
+Python library used to encrypt and decrypt strings in the simplest possible way, while also being incredibly secure.
+## Requirements
+
+
+- **Python** 3 or later.
+
+## Installation
+
+Install some Python utilities along with some libraries and other stuff:
+
+~~~
+pip install cryptocode
+~~~
+
+## Basic usage
+Encrypting a message:
+
+~~~
+>>> import cryptocode
+>>> myEncryptedMessage = cryptocode.encrypt("I like trains", "password123")
+>>> print(myEncryptedMessage)
+M+Wykmlub0z7FhEdmA==*PvAbXRNx0SiSDHHxLsKZ5w==*ihQM/fdkgrX3G+yOItyAUQ==*QFNDmuUP1ysgo01/P2MNpg==
+~~~
+
+The first parameter is the string you want to encrypt. The second parameter is the password, which will be used for decrypting the string.
+
+Decrypting a message"
+~~~
+>>> import cryptocode
+>>> myDecryptedMessage = cryptocode.decrypt("M+Wykmlub0z7FhEdmA==*PvAbXRNx0SiSDHHxLsKZ5w==*ihQM/fdkgrX3G+yOItyAUQ==*QFNDmuUP1ysgo01/P2MNpg==", "password123")
+>>> print(myDecryptedMessage)
+I like trains
+~~~
+The first parameter is the encrypted string and the second parameter is the password. If the password is incorrect, decrypt function will return `False`.
+
+## Example
+Here, we will be creating a simple "trial product key". This is useful if you have software that you would like people to use temporarily.
+In this example, we will be letting the user use the product for 2 hours. The password we will be using is ``cryptocode is amazing``.
+
+Code on the server side:
+~~~
+import cryptocode
+import time
+hours = 2
+messageToEncrypt = str(time.time() + hours * 60 * 60)
+## Hours * 60 * 60 is necessary because we need to turn the hours into seconds, since the timestamp is in seconds.
+cryptocode.encrypt(messageToEncrypt, "cryptocode is amazing")
+~~~
+
+Code on the client side:
+~~~
+import cryptocode
+import time
+import sys
+#Function to verify that the key is valid:
+def check_valid(key):
+ message = cryptocode.decrypt(key, 'cryptocode is amazing')
+ if message == False:
+ #The key is incorrect!
+ return False
+ if float(message) >= time.time():
+ return True
+ else:
+ #The key has expired!
+ return False
+userKeyInput = input("Please enter your product key.")
+keyChecked = check_valid(userKeyInput)
+if keyChecked == True:
+ print("You are good to go!")
+if keyChecked == False:
+ print("You have either entered an invalid key or your time has expired. Sorry!")
+ sys.exit()
+~~~
+
+
+
+
+%package help
+Summary: Development documents and examples for cryptocode
+Provides: python3-cryptocode-doc
+%description help
+# cryptocode
+
+Python library used to encrypt and decrypt strings in the simplest possible way, while also being incredibly secure.
+## Requirements
+
+
+- **Python** 3 or later.
+
+## Installation
+
+Install some Python utilities along with some libraries and other stuff:
+
+~~~
+pip install cryptocode
+~~~
+
+## Basic usage
+Encrypting a message:
+
+~~~
+>>> import cryptocode
+>>> myEncryptedMessage = cryptocode.encrypt("I like trains", "password123")
+>>> print(myEncryptedMessage)
+M+Wykmlub0z7FhEdmA==*PvAbXRNx0SiSDHHxLsKZ5w==*ihQM/fdkgrX3G+yOItyAUQ==*QFNDmuUP1ysgo01/P2MNpg==
+~~~
+
+The first parameter is the string you want to encrypt. The second parameter is the password, which will be used for decrypting the string.
+
+Decrypting a message"
+~~~
+>>> import cryptocode
+>>> myDecryptedMessage = cryptocode.decrypt("M+Wykmlub0z7FhEdmA==*PvAbXRNx0SiSDHHxLsKZ5w==*ihQM/fdkgrX3G+yOItyAUQ==*QFNDmuUP1ysgo01/P2MNpg==", "password123")
+>>> print(myDecryptedMessage)
+I like trains
+~~~
+The first parameter is the encrypted string and the second parameter is the password. If the password is incorrect, decrypt function will return `False`.
+
+## Example
+Here, we will be creating a simple "trial product key". This is useful if you have software that you would like people to use temporarily.
+In this example, we will be letting the user use the product for 2 hours. The password we will be using is ``cryptocode is amazing``.
+
+Code on the server side:
+~~~
+import cryptocode
+import time
+hours = 2
+messageToEncrypt = str(time.time() + hours * 60 * 60)
+## Hours * 60 * 60 is necessary because we need to turn the hours into seconds, since the timestamp is in seconds.
+cryptocode.encrypt(messageToEncrypt, "cryptocode is amazing")
+~~~
+
+Code on the client side:
+~~~
+import cryptocode
+import time
+import sys
+#Function to verify that the key is valid:
+def check_valid(key):
+ message = cryptocode.decrypt(key, 'cryptocode is amazing')
+ if message == False:
+ #The key is incorrect!
+ return False
+ if float(message) >= time.time():
+ return True
+ else:
+ #The key has expired!
+ return False
+userKeyInput = input("Please enter your product key.")
+keyChecked = check_valid(userKeyInput)
+if keyChecked == True:
+ print("You are good to go!")
+if keyChecked == False:
+ print("You have either entered an invalid key or your time has expired. Sorry!")
+ sys.exit()
+~~~
+
+
+
+
+%prep
+%autosetup -n cryptocode-0.1
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-cryptocode -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Mon Apr 10 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..c622ff3
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+a5297825a5e052fde3229d4b526de22b cryptocode-0.1.tar.gz