Comments (4)
Out of curiousity, what type of data are you passing into the encrypt/decrypt functions?
As normally in Python 2 it's a str (or bytes instance, which is still an instance of str).
from pydes.
m = SHA.new(key)
digest = m.digest()
.
.
.
key_bytes = bytearray(key_bytes)
c = pyDes.triple_des(key_bytes, mode=pyDes.CBC, IV="\0\0\0\0\0\0\0\0", pad=None, padmode=pyDes.PAD_PKCS5)
using as above code format. It's giving an above mention error.
from pydes.
Please tell me where I am using wrong method in above mention code.
from pydes.
The workaround would be to use the original bytes object, or convert the bytearray to bytes:
# key_bytes = bytearray(key_bytes) # Don't convert to bytearray
c = pyDes.triple_des(key_bytes, mode=pyDes.CBC, IV="\0\0\0\0\0\0\0\0", pad=None, padmode=pyDes.PAD_PKCS5)
or convert the key to bytes before passing to pyDes:
key_bytes = bytearray(key_bytes)
c = pyDes.triple_des(bytes(key_bytes), mode=pyDes.CBC, IV="\0\0\0\0\0\0\0\0", pad=None, padmode=pyDes.PAD_PKCS5)
from pydes.
Related Issues (15)
- TypeError: unsupported operand type(s) for +=: 'dict' and 'bytes' HOT 1
- ValueError: pyDes can only work with encoded strings, not Unicode. HOT 2
- 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
- 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.