Comments (2)
print ("%r" %cipher_text)
from pydes.
The r'...' produces a (unicode) string in Python3.
When using Python3 - you would need to convert to bytes to pass into pyDes - example:
$ python3
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyDes
>>> key = '01234567'
>>> d = pyDes.des('01234567', padmode=pyDes.PAD_PKCS5)
>>> text = r'一对一异或操作,得到结果,其中,"ord(char)"得到该字符对应的ASCII码,"chr(int)"刚好相反'
>>> d.encrypt(text)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/toddw/.local/lib/python3.8/site-packages/pyDes.py", line 655, in encrypt
data = self._guardAgainstUnicode(data)
File "/home/toddw/.local/lib/python3.8/site-packages/pyDes.py", line 241, in _guardAgainstUnicode
raise ValueError("pyDes can only work with encoded strings, not Unicode.")
ValueError: pyDes can only work with encoded strings, not Unicode.
>>> type(text)
<class 'str'>
>>> print ('%r' % (text, ))
'一对一异或操作,得到结果,其中,"ord(char)"得到该字符对应的ASCII码,"chr(int)"刚好相反'
>>> d.encrypt(bytes(text, 'utf-8'))
b'\x05\x8b9\xad\xa8\xaa5Y\x15Q\x8b\xfd\x97O\xa8\xed\xa9\x9dz\x0c\xbe\xbc\x12\x8b\xb7\x89\x13\x9b/,\x85\xa2[^\x9e%w\n<_\xa7\xe9{\x81#\xbb\tt\x96\x94\x84ip&\xde[\xab9\xdeP/\x94\xc7\xe6\xe0\x14W)\x85-\xf8Q\x19G\x92q\xe4^wq\x93\xeb\xe1\x9c\x0c\x1a\xf9\x07\xeb\xea\x82\xd0\x9a\xad\xa7\x0e/\xb3\xa765,\xf6\xf7\x1a\xeef\xca\x88\x8a\x91P'
from pydes.
Related Issues (15)
- TypeError: unsupported operand type(s) for +=: 'dict' and 'bytes' HOT 1
- Invalid data length, data must be a multiple of 8 bytes HOT 1
- Can you help me implement such type of C# code with pyDes?
- Cannot collect pydes HOT 1
- Cannot collect pydes HOT 4
- can't import pyDes HOT 2
- Canonical "latest" version
- Create encrypted passwords for VNC? HOT 2
- why des and triple_des the key is different HOT 1
- Pydes Error generating triple des conversion HOT 4
- Different implementations HOT 1
- CBC mode adds extra bytes HOT 2
- Do not support "Padding:PKCS7",Please HOT 3
- About unpad data function question HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pydes.